Bug 1287723 - Fix test_screenshot.py to properly wait for new chrome window to be loaded. r=automatedtester

MozReview-Commit-ID: KiFGbNdddJe

--HG--
extra : rebase_source : 87ccbb02cdb45531efc7fe948c57c10e9e03b547
This commit is contained in:
Henrik Skupin 2016-07-21 11:10:14 +02:00
Родитель 0b8cfd1d36
Коммит faa2229a5e
1 изменённых файлов: 11 добавлений и 7 удалений

Просмотреть файл

@ -6,7 +6,6 @@ import base64
import hashlib
import imghdr
import struct
import time
import urllib
from unittest import skip
@ -87,16 +86,21 @@ class Chrome(ScreenCaptureTestCase):
# <window> element, which does not exist for secondary windows.
def test_secondary_windows(self):
ss = self.marionette.screenshot()
self.marionette.execute_script("""
window.open('chrome://marionette/content/doesnotexist.xul',
self.marionette.execute_async_script("""
win = window.open('chrome://marionette/content/doesnotexist.xul',
'foo',
'chrome');
// Bug 1288339 - We don't wait for readyState to be complete yet
waitForWindow = function() {
if (win.document.readyState != 'complete') {
win.setTimeout(this, 100);
}
marionetteScriptFinished(true);
}()
""")
self.marionette.switch_to_window("foo")
# there can be a race between opening and registering the window
# and switching to it. Waiting a tiny amount of time is enough not to
# break anything.
time.sleep(0.002)
ss = self.marionette.screenshot()
size = self.get_image_dimensions(ss)
self.assert_png(ss)