blob: 53a6851bd98c11128429f358fef8ed687c6704da [file] [log] [blame]
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from autotest_lib.client.common_lib import error
from autotest_lib.client.cros.enterprise import enterprise_policy_base
class policy_DefaultGeolocationSetting(
Test effect of DefaultGeolocationSetting policy on Chrome OS.
This test will set the policy, then will check the geolocation setting
to determine if the policy worked or not.
The policy sets the result to variable so its easier to call/return
via the EvaluateJavaScript function.
version = 1
POLICY_NAME = 'DefaultGeolocationSetting'
policy_setting = {'granted': 1,
'denied': 2,
'prompt': 3,
'not_set': None}
def _notification_check(self, case):
Navigates to a page, and query the geolocation status.
@param case: the setting of the DefaultGeolocationSetting Policy
tab = self.navigate_to_url('chrome://policy')
geo_status = """navigator.permissions.query({name:'geolocation'})
.then(function(permissionStatus) {
geo_result = permissionStatus.state;
content = tab.EvaluateJavaScript('geo_result')
# prompt is the default setting
if case == 'not_set':
case = 'prompt'
if content != case:
raise error.TestError('Geolocation Setting did not match setting.'
'Expected {e} but received {r}'
.format(e=case, r=content))
def run_once(self, case):
Setup and run the test configured for the specified test case.
@param case: Name of the test case to run.
self.POLICY_NAME: self.policy_setting[case]})