15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#!/usr/bin/env python 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Copyright (c) 2012 The Chromium Authors. All rights reserved. 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# found in the LICENSE file. 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)import logging 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)import os 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)import re 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)import shutil 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)import time 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)import pyauto_functional # Must be imported before pyauto 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)import pyauto 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)import test_utils 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)from selenium.webdriver.common.action_chains import ActionChains 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)from selenium.common.exceptions import WebDriverException 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)from selenium.webdriver.common.keys import Keys 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)from webdriver_pages import settings 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class FullscreenMouselockTest(pyauto.PyUITest): 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """TestCase for Fullscreen and Mouse Lock.""" 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def setUp(self): 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pyauto.PyUITest.setUp(self) 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver = self.NewWebDriver() 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Get the hostname pattern (e.g. http://127.0.0.1:57622). 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._hostname_pattern = ( 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) re.sub('/files/$', '', self.GetHttpURLForDataPath(''))) 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def Debug(self): 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Test method for experimentation. 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This method will not run automatically. 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) page = settings.ContentSettingsPage.FromNavigation(self._driver) 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) import pdb 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pdb.set_trace() 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def ExtraChromeFlags(self): 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Ensures Chrome is launched with custom flags. 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Returns: 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) A list of extra flags to pass to Chrome when it is launched. 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Extra flag needed by scroll performance tests. 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return super(FullscreenMouselockTest, 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self).ExtraChromeFlags() + ['--enable-pointer-lock'] 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testFullScreenMouseLockHooks(self): 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify fullscreen and mouse lock automation hooks work.""" 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath( 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Starting off we shouldn't be fullscreen 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsFullscreenForBrowser()) 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsFullscreenForTab()) 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Go fullscreen 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('enterFullscreen').click() 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsFullscreenForTab)) 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Bubble should be up prompting to allow fullscreen 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.IsFullscreenBubbleDisplayed()) 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.IsFullscreenBubbleDisplayingButtons()) 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.IsFullscreenPermissionRequested()) 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Accept bubble, it should go away. 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AcceptCurrentFullscreenOrMouseLockRequest() 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil( 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lambda: not self.IsFullscreenBubbleDisplayingButtons())) 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Try to lock mouse, it won't lock yet but permision will be requested. 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsMouseLocked()) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('lockMouse1').click() 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsMouseLocked()) 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Deny mouse lock. 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.DenyCurrentFullscreenOrMouseLockRequest() 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil( 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lambda: not self.IsFullscreenBubbleDisplayingButtons())) 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsMouseLocked()) 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Try mouse lock again, and accept it. 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('lockMouse1').click() 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AcceptCurrentFullscreenOrMouseLockRequest() 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsMouseLocked)) 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # The following doesn't work - as sending the key to the input field isn't 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # picked up by the browser. :( Need an alternative way. 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # # Ideally we wouldn't target a specific element, we'd just send keys to 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # # whatever the current keyboard focus was. 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # keys_target = driver.find_element_by_id('sendKeysTarget') 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # # ESC key should exit fullscreen and mouse lock. 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # print "# ESC key should exit fullscreen and mouse lock." 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # keys_target.send_keys(Keys.ESCAPE) 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForBrowser())) 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab())) 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked())) 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # # Check we can go browser fullscreen 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # print "# Check we can go browser fullscreen" 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # keys_target.send_keys(Keys.F11) 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # self.assertTrue(self.WaitUntil(self.IsFullscreenForBrowser)) 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def _LaunchFSAndExpectPrompt(self, button_action='enterFullscreen'): 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Helper function to launch fullscreen and expect a prompt. 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Fullscreen is initiated and a bubble prompt appears asking to allow or 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) cancel from fullscreen mode. The actual fullscreen mode doesn't take place 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) until after approving the prompt. 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) If the helper is not successful then the test will fail. 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Args: 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) button_action: The button id to click to initiate an action. Default is to 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) click enterFullscreen. 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath( 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Should not be in fullscreen mode during initial launch. 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsFullscreenForBrowser()) 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsFullscreenForTab()) 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Go into fullscreen mode. 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id(button_action).click() 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsFullscreenForTab)) 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Bubble should display prompting to allow fullscreen. 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.IsFullscreenPermissionRequested()) 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def _InitiateBrowserFullscreen(self): 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Helper function that initiates browser fullscreen.""" 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath( 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Should not be in fullscreen mode during initial launch. 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsFullscreenForBrowser()) 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsFullscreenForTab()) 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Initiate browser fullscreen. 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.ApplyAccelerator(pyauto.IDC_FULLSCREEN) 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsFullscreenForBrowser)) 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab())) 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked())) 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def _InitiateTabFullscreen(self): 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Helper function that initiates tab fullscreen.""" 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath( 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Initiate tab fullscreen. 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('enterFullscreen').click() 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsFullscreenForTab)) 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def _AcceptFullscreenOrMouseLockRequest(self): 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Helper function to accept fullscreen or mouse lock request.""" 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AcceptCurrentFullscreenOrMouseLockRequest() 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil( 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lambda: not self.IsFullscreenBubbleDisplayingButtons())) 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def _EnableFullscreenAndMouseLockMode(self): 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Helper function to enable fullscreen and mouse lock mode.""" 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._LaunchFSAndExpectPrompt(button_action='enterFullscreenAndLockMouse1') 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Allow fullscreen. 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AcceptCurrentFullscreenOrMouseLockRequest() 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # The wait is needed due to crbug.com/123396. Should be able to click the 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # fullscreen and mouselock button and be both accepted in a single action. 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Allow mouse lock. 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AcceptCurrentFullscreenOrMouseLockRequest() 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsMouseLocked)) 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def _EnableMouseLockMode(self, button_action='lockMouse1'): 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Helper function to enable mouse lock mode. 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Args: 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) button_action: The button id to click to initiate an action. Default is to 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) click lockMouse1. 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id(button_action).click() 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AcceptCurrentFullscreenOrMouseLockRequest() 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.IsMouseLocked()) 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def _EnableAndReturnLockMouseResult(self): 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Helper function to enable and return mouse lock result.""" 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath( 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('lockMouse2').click() 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue( 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.WaitUntil(self.IsMouseLockPermissionRequested)) 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AcceptCurrentFullscreenOrMouseLockRequest() 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Waits until lock_result gets 'success' or 'failure'. 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return self._driver.execute_script('return lock_result') 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def _ClickAnchorLink(self): 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Clicks the anchor link until it's successfully clicked. 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Clicks on the anchor link and compares the js |clicked_elem_ID| variabled 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) with the anchor id. Returns True if the link is clicked. 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) element_id = 'anchor' 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Catch WebDriverException: u'Element is not clickable at point (185.5, 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # 669.5). Instead another element would receive the click. 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) try: 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id(element_id).click() 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) except WebDriverException: 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return False 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return self._driver.execute_script('return clicked_elem_ID') == element_id 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testPrefsForFullscreenAllowed(self): 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify prefs when fullscreen is allowed.""" 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._LaunchFSAndExpectPrompt() 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._AcceptFullscreenOrMouseLockRequest() 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content_settings = ( 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.GetPrefsInfo().Prefs()['profile']['content_settings']) 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertEqual( 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) {self._hostname_pattern + ',*': {'fullscreen': 1}}, # Allow hostname. 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content_settings['pattern_pairs'], 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Saved hostname pattern does not match expected pattern.') 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testPrefsForFullscreenExit(self): 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify prefs is empty when exit fullscreen mode before allowing.""" 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._LaunchFSAndExpectPrompt() 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('exitFullscreen').click() 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Verify exit from fullscreen mode. 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab())) 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content_settings = ( 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.GetPrefsInfo().Prefs()['profile']['content_settings']) 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertEqual( 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) {}, content_settings['pattern_pairs'], 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Patterns saved when there should be none.') 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testPatternsForFSAndML(self): 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify hostname pattern and behavior for allowed mouse cursor lock. 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) To lock the mouse, the browser needs to be in fullscreen mode. 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._EnableFullscreenAndMouseLockMode() 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._EnableMouseLockMode() 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) expected_pattern = ( 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) {self._hostname_pattern + ',*': {'fullscreen': 1, 'mouselock': 1}}) 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content_settings = ( 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.GetPrefsInfo().Prefs()['profile']['content_settings']) 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertEqual( 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) expected_pattern, content_settings['pattern_pairs'], 2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Saved hostname and behavior patterns do not match expected.') 2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testPatternsForAllowMouseLock(self): 2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify hostname pattern and behavior for allowed mouse cursor lock. 2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Enable fullscreen mode and enable mouse lock separately. 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._LaunchFSAndExpectPrompt() 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AcceptCurrentFullscreenOrMouseLockRequest() 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._EnableMouseLockMode() 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) expected_pattern = ( 2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) {self._hostname_pattern + ',*': {'fullscreen': 1, 'mouselock': 1}}) 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content_settings = ( 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.GetPrefsInfo().Prefs()['profile']['content_settings']) 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertEqual( 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) expected_pattern, content_settings['pattern_pairs'], 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Saved hostname and behavior patterns do not match expected.') 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testNoMouseLockRequest(self): 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse lock request does not appear. 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) When allowing all sites to disable the mouse cursor, the mouse lock request 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bubble should not show. The mouse cursor should be automatically disabled 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) when clicking on a disable mouse button. 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Allow all sites to disable mouse cursor. 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.SetPrefs(pyauto.kDefaultContentSettings, {u'mouselock': 1}) 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._LaunchFSAndExpectPrompt() 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Allow for fullscreen mode. 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._AcceptFullscreenOrMouseLockRequest() 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.set_script_timeout(2) 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Receive callback status (success or failure) from javascript that the 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # click has registered and the mouse lock status has changed. 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result = self._driver.execute_async_script( 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'lockMouse1(arguments[arguments.length - 1])') 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertEqual(lock_result, 'success', msg='Mouse lock unsuccessful.') 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil( 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lambda: not self.IsMouseLockPermissionRequested())) 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.IsMouseLocked()) 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testUnableToLockMouse(self): 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse lock is disabled. 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) When not allowing any site to disable the mouse cursor, the mouse lock 2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) request bubble should not show and the mouse cursor should not be disabled. 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Do not allow any site to disable mouse cursor. 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.SetPrefs(pyauto.kDefaultContentSettings, {u'mouselock': 2}) 2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._LaunchFSAndExpectPrompt() 2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Allow for fullscreen mode. 2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._AcceptFullscreenOrMouseLockRequest() 2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.set_script_timeout(2) 3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Receive callback status (success or failure) from javascript that the 3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # click has registered and the mouse lock status has changed. 3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result = self._driver.execute_async_script( 3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'lockMouse1(arguments[arguments.length - 1])') 3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertEqual(lock_result, 'failure', msg='Mouse locked unexpectedly.') 3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil( 3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lambda: not self.IsMouseLockPermissionRequested())) 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked())) 3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testEnterTabFSWhileInBrowserFS(self): 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify able to enter into tab fullscreen while in browser fullscreen.""" 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._InitiateBrowserFullscreen() 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Initiate tab fullscreen. 3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('enterFullscreen').click() 3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab())) 3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked())) 3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testMouseLockInBrowserFS(self): 3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse lock in browser fullscreen requires allow prompt.""" 3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._InitiateBrowserFullscreen() 3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.set_script_timeout(2) 3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.execute_script('lockMouse1AndSetLockResult()') 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Bubble should display prompting to allow mouselock. 3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AcceptCurrentFullscreenOrMouseLockRequest() 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Waits until lock_result gets 'success' or 'failure'. 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result = self._driver.execute_script('return lock_result') 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertEqual(lock_result, 'success', 3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Mouse was not locked in browser fullscreen.') 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testNoMouseLockWhenCancelFS(self): 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse lock breaks when canceling tab fullscreen. 3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This test uses javascript to initiate exit of tab fullscreen after mouse 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock success callback. 3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._LaunchFSAndExpectPrompt() 3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.set_script_timeout(2) 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result = self._driver.execute_script('lockMouse1AndSetLockResult()') 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue( 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.WaitUntil(lambda: self.IsMouseLockPermissionRequested())) 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AcceptCurrentFullscreenOrMouseLockRequest() 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsMouseLocked)) 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Waits until lock_result gets 'success' or 'failure'. 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result = self._driver.execute_script('return lock_result') 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertEqual( 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result, 'success', msg='Mouse is not locked.') 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.execute_script('document.webkitCancelFullScreen()') 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab()), 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Tab is still in fullscreen.') 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked()), 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Mouse is still locked after exiting fullscreen.') 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testNoTabFSExitWhenJSExitMouseLock(self): 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify tab fullscreen does not exit when javascript init mouse lock exit. 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This test uses javascript to initiate exit of mouse lock after mouse 3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock success callback. 3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._LaunchFSAndExpectPrompt() 3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._EnableMouseLockMode() 3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.execute_script('navigator.webkitPointer.unlock()') 3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.WaitUntil(lambda: not self.IsMouseLocked()) 3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.IsFullscreenForTab(), msg='Tab fullscreen was lost.') 3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testMouseLockExitWhenAlertDialogShow(self): 3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse lock breaks when alert dialog appears.""" 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._LaunchFSAndExpectPrompt() 3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._EnableMouseLockMode() 3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Need to catch the exception here since the alert dialog raises 3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # a WebDriverException due to a modal dialog. 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) from selenium.common.exceptions import WebDriverException 3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) try: 3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.execute_script('alert("A modal dialog")') 3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) except WebDriverException: 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pass 3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab()), 3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Tab fullscreen was lost.') 3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked()), 3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Mouse is still locked') 3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testMouseLockExitWhenBrowserLoseFocus(self): 3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse lock breaks when browser loses focus. 3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Mouse lock breaks when the focus is placed on another new window. 3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._LaunchFSAndExpectPrompt() 3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AcceptCurrentFullscreenOrMouseLockRequest() 3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Open a new window to shift focus away. 3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.OpenNewBrowserWindow(True) 3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab())) 3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked()), 3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Mouse lock did not break when browser lost focus.') 3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testMouseLockLostOnReload(self): 3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse lock is lost on page reload.""" 3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath( 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._EnableMouseLockMode() 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.ReloadActiveTab() 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsMouseLocked()), 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Mouse lock did not break when page is reloaded.') 4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testNoMLBubbleWhenTabLoseFocus(self): 4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse lock bubble goes away when tab loses focus.""" 4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath( 4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('lockMouse1').click() 4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsMouseLockPermissionRequested)) 4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.AppendTab(pyauto.GURL('chrome://newtab')) 4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil( 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lambda: not self.IsFullscreenBubbleDisplayingButtons()), 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Mouse lock bubble did not clear when tab lost focus.') 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testTabFSExitWhenNavBackToPrevPage(self): 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify tab fullscreen exit when navigating back to previous page. 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This test navigates to a new page while in tab fullscreen mode by using 4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GoBack() to navigate to the previous google.html page. 4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath('google', 'google.html')) 4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._InitiateTabFullscreen() 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.TabGoBack() 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse( 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.IsFullscreenForTab(), 4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Tab fullscreen did not exit when navigating to a new page.') 4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testTabFSExitWhenNavToNewPage(self): 4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify tab fullscreen exit when navigating to a new website. 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This test navigates to a new website while in tab fullscreen. 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._InitiateTabFullscreen() 4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath('google', 'google.html')) 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse( 4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.IsFullscreenForTab(), 4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Tab fullscreen did not exit when navigating to a new website.') 4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testTabFSDoesNotExitForAnchorLinks(self): 4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify tab fullscreen does not exit for anchor links. 4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Tab fullscreen should not exit when following a link to the same page such 4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) as example.html#anchor. 4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._InitiateTabFullscreen() 4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self._ClickAnchorLink)) 4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue( 4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.WaitUntil(self.IsFullscreenForTab), 4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Tab fullscreen should not exit when clicking on an anchor link.') 4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testMLExitWhenNavBackToPrevPage(self): 4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse lock exit when navigating back to previous page. 4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This test navigates to a new page while mouse lock is activated by using 4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GoBack() to navigate to the previous google.html page. 4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath('google', 'google.html')) 4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result = self._EnableAndReturnLockMouseResult() 4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertEqual( 4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result, 'success', msg='Mouse is not locked.') 4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.TabGoBack() 4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse( 4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.IsMouseLocked(), 4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Mouse lock did not exit when navigating to the prev page.') 4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testMLExitWhenNavToNewPage(self): 4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse lock exit when navigating to a new website.""" 4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result = self._EnableAndReturnLockMouseResult() 4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertEqual( 4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result, 'success', msg='Mouse is not locked.') 4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath('google', 'google.html')) 4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse( 4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.IsMouseLocked(), 4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Mouse lock did not exit when navigating to a new website.') 4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def testMLDoesNotExitForAnchorLinks(self): 4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse lock does not exit for anchor links. 4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Mouse lock should not exist when following a link to the same page such as 4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) example.html#anchor. 4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result = self._EnableAndReturnLockMouseResult() 4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertEqual( 4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lock_result, 'success', msg='Mouse is not locked.') 4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ActionChains(self._driver).move_to_element( 4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('anchor')).click().perform() 4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsMouseLocked), 4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Mouse lock broke when clicking on an anchor link.') 4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def ExitTabFSToBrowserFS(self): 4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify exiting tab fullscreen leaves browser in browser fullscreen. 4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This test is semi-automated. 4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) The browser initiates browser fullscreen, then initiates tab fullscreen. The 4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test verifies that existing tab fullscreen by simulating ESC key press or 4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) clicking the js function to exitFullscreen() will exit the tab fullscreen 4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) leaving browser fullscreen intact. 4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._InitiateBrowserFullscreen() 5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Initiate tab fullscreen. 5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('enterFullscreen').click() 5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab())) 5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Require manual intervention to send ESC key due to crbug.com/123930. 5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # TODO(dyu): Update to a full test once associated bug is fixed. 5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) logging.info('Press ESC key to exit tab fullscreen.') 5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) time.sleep(5) 5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab())) 5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForBrowser()), 5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Not in browser fullscreen mode.') 5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('enterFullscreen').click() 5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab())) 5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Exit tab fullscreen by clicking button exitFullscreen(). 5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('exitFullscreen').click() 5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab())) 5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForBrowser()), 5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Not in browser fullscreen mode.') 5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def F11KeyExitsTabAndBrowserFS(self): 5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify existing tab fullscreen exits all fullscreen modes. 5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This test is semi-automated. 5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) The browser initiates browser fullscreen, then initiates tab fullscreen. The 5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test verifies that existing tab fullscreen by simulating F11 key press or 5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CMD + SHIFT + F keys on the Mac will exit the tab fullscreen and the 5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser fullscreen. 5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._InitiateBrowserFullscreen() 5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Initiate tab fullscreen. 5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('enterFullscreen').click() 5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: self.IsFullscreenForTab())) 5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Require manual intervention to send F11 key due to crbug.com/123930. 5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # TODO(dyu): Update to a full test once associated bug is fixed. 5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) logging.info('Press F11 key to exit tab fullscreen.') 5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) time.sleep(5) 5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForTab())) 5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(lambda: not self.IsFullscreenForBrowser()), 5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) msg='Browser is in fullscreen mode.') 5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def SearchForTextOutsideOfContainer(self): 5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify text outside of container is not visible when fullscreen. 5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This test is semi-automated. 5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Verify this test manually until there is a way to find text on screen 5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) without using FindInPage(). 5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) The text that is outside of the fullscreen container should only be visible 5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) when fullscreen is off. The text should not be visible while in fullscreen 5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) mode. 5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 5545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath( 5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Should not be in fullscreen mode during initial launch. 5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsFullscreenForBrowser()) 5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsFullscreenForTab()) 5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue( 5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.WaitUntil(lambda: self.FindInPage( 5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'This text is outside of the container')['match_count'], 5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) expect_retval=1)) 5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Go into fullscreen mode. 5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('enterFullscreen').click() 5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsFullscreenForTab)) 5665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) time.sleep(5) 5675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # TODO(dyu): find a way to verify on screen text instead of using 5685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # FindInPage() which searches for text in the HTML. 5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def SameMouseLockMovement(self): 5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify the correct feel of mouse movement data when mouse is locked. 5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This test is semi-automated. 5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This test loads the same web page in two different tabs while in mouse lock 5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) mode. Each tab loads the web page from a different URL (e.g. by loading it 5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) from a localhost server and a file url). The test verifies 5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) that the mouse lock movements work the same in both 5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) tabs. 5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) url1 = self.GetHttpURLForDataPath( 5825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'fullscreen_mouselock', 'fullscreen_mouselock.html') 5835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) url2 = self.GetFileURLForDataPath( 5845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'fullscreen_mouselock', 'fullscreen_mouselock.html') 5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) tab2 = 'f1-4' 5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(url1) 5875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.RunCommand(pyauto.IDC_NEW_TAB) # Open new tab. 5885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(url2, 0, 1) 5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.switch_to_window(tab2) 5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._EnableMouseLockMode() # Lock mouse in tab 2. 5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) raw_input('Manually move the mouse cursor on the page in tab 2. Shift+Tab \ 5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) into tab 1, click on lockMouse1() button, and move the mouse \ 5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) cursor on the page in tab 1. Verify mouse movement is smooth.') 5945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) def MouseEventsIndependentOfExitBubble(self): 5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """Verify mouse events are independent of the exit FS exit bubble for ML. 5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Mouse movement events should work immediately when mouse lock is activated. 5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) The events should not be blocked waiting for the exit instruction bubble to 6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) clear. 6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) """ 6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.NavigateToURL(self.GetHttpURLForDataPath( 6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'fullscreen_mouselock', 'fullscreen_mouselock.html')) 6045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Should not be in fullscreen mode during initial launch. 6055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsFullscreenForBrowser()) 6065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertFalse(self.IsFullscreenForTab()) 6075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) # Go into fullscreen mode. 6085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._driver.find_element_by_id('enterFullscreen').click() 6095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self.assertTrue(self.WaitUntil(self.IsFullscreenForTab)) 6105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) self._EnableMouseLockMode() 6115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) raw_input( 6125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) '1. Move the mouse, see movement data being received by the page.\ 6135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2. Press ESC key.\ 6145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3. Lock the mouse without going fullscreen. Click lockMouse1() button.\ 6155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Verify: The mouse movement events should work immediately.') 6165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)if __name__ == '__main__': 6185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pyauto_functional.Main() 619