Skip to content

Commit db16a75

Browse files
jgrahammoz-wptsync-bot
authored andcommitted
Bug 1522790 [wpt PR 45576] - [Gecko Bug 1522790] Use marionette new window command to open wptrunner windows, a=testonly
Automatic update from web-platform-tests Use marionette new window command to open wptrunner windows Differential Revision: https://phabricator.services.mozilla.com/D23972 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1522790 gecko-commit: 9e98e314a251258d817c1a93020dcf439dd01b42 gecko-reviewers: jgraham -- [wpt] Fix intermittent test failures for short timer. Depends on D23972 Differential Revision: https://phabricator.services.mozilla.com/D204234 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1522790 gecko-commit: 3acba738b962607ed98937ebd8d40d77fb001c48 gecko-reviewers: whimboo -- [wpt] Fix intermittent failures in font-face-[003, 004].html. Differential Revision: https://phabricator.services.mozilla.com/D206622 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1522790 gecko-commit: 251e04906ebfda2d88823f1e526a10f1c2d0fa81 gecko-reviewers: jgraham -- [wptrunner] Fix MarionetteWindowProtocolPart.set_rect() for optional arguments. Differential Revision: https://phabricator.services.mozilla.com/D206623 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1522790 gecko-commit: f8d941b403d063e1c49011783a4f76ccfe806495 gecko-reviewers: jgraham -- Remove import of unused time module -- wpt-commits: 8f3f54589108bb739a6abb153717ad39e0dd1df1, ef70df47c28272b0642d25f70f8e5d3d5ebb7b32, 19320f2a3fd3c8cd3649b8418a7f6a12a9ff576f, 9826d2b6a4472d07056fa16ae151fa943bebc26d, 149d525c8ab1b607d030da6b49d85e9d5890b5b2 wpt-pr: 45576
1 parent 7a6851d commit db16a75

File tree

7 files changed

+42
-86
lines changed

7 files changed

+42
-86
lines changed

testing/web-platform/tests/css/css-scoping/font-face-003.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</style>
1414
<div id="host"><span id="in-document">1234567890</span></div>
1515
<script>
16-
test(function() {
16+
promise_test(async function () {
1717
host.attachShadow({ mode: "open" }).innerHTML = `
1818
<style>
1919
:host {
@@ -24,6 +24,7 @@
2424
<span id="in-shadow">0123456789</span>
2525
`;
2626

27+
await document.fonts.ready;
2728
assert_equals(document.getElementById('in-document').offsetWidth, 160);
2829
assert_equals(host.shadowRoot.getElementById('in-shadow').offsetWidth, 160);
2930
}, "@font-face from document applies to :host");

testing/web-platform/tests/css/css-scoping/font-face-004.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</style>
1515
<div id="host"><span id="in-document">1234567890</span></div>
1616
<script>
17-
test(function() {
17+
promise_test(async function() {
1818
host.attachShadow({ mode: "open" }).innerHTML = `
1919
<style>
2020
::slotted(#in-document) {
@@ -25,6 +25,7 @@
2525
<span id="in-shadow">0123456789</span>
2626
`;
2727

28+
await document.fonts.ready;
2829
assert_equals(document.getElementById('in-document').offsetWidth, 160);
2930
assert_not_equals(host.shadowRoot.getElementById('in-shadow').offsetWidth, 160);
3031
}, "@font-face from document applies to a slotted element");

testing/web-platform/tests/html/semantics/disabled-elements/event-propagate-disabled.tentative.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@
153153
await new Promise(resolve => t.step_timeout(resolve, 0));
154154

155155
const expected = isDisabledFormControl(element) ? expectedEvents : nonDisabledExpectedEvents;
156-
assert_array_equals(observedEvents.map(e => e.type), expected, "Observed events");
156+
157+
t.step_wait_func_done(() => observedEvents.length > 0,
158+
() => assert_array_equals(observedEvents.map(e => e.type), expected, "Observed events"),
159+
undefined, 1000, 10);
160+
;
157161

158162
for (const observed of observedEvents) {
159163
assert_equals(observed.target, target, `${observed.type}.target`)

testing/web-platform/tests/html/webappapis/timers/setinterval-cross-realm-callback-report-exception.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
`), 4);
2424
window.clearThisInterval = () => { frames[0].clearInterval(id); };
2525

26-
t.step_timeout(() => {
27-
assert_array_equals(onerrorCalls, ["frame1"]);
28-
t.done();
29-
}, 8);
26+
t.step_wait_func_done(() => onerrorCalls.length > 0,
27+
() => assert_array_equals(onerrorCalls, ["frame1"]),
28+
undefined, 1000, 10);
3029
});
3130
});
3231
</script>

testing/web-platform/tests/html/webappapis/timers/settimeout-cross-realm-callback-report-exception.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
window.onload = t.step_func(() => {
2020
frames[0].setTimeout(new frames[1].Function(`throw new parent.frames[2].Error("PASS");`), 4);
2121

22-
t.step_timeout(() => {
23-
assert_array_equals(onerrorCalls, ["frame1"]);
24-
t.done();
25-
}, 8);
22+
t.step_wait_func_done(() => onerrorCalls.length > 0,
23+
() => assert_array_equals(onerrorCalls, ["frame1"]),
24+
undefined, 1000, 10);
2625
});
2726
});
2827
</script>

testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executormarionette.py

+19-63
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import json
44
import os
55
import threading
6-
import time
76
import traceback
87
import uuid
98

@@ -103,6 +102,9 @@ def set_timeout(self, timeout):
103102
self.marionette.timeout.script = timeout
104103
self.timeout = timeout
105104

105+
def create_window(self, type="tab", **kwargs):
106+
return self.marionette.open(type=type, focus=True)["handle"]
107+
106108
@property
107109
def current_window(self):
108110
return self.marionette.current_window_handle
@@ -233,57 +235,6 @@ def dismiss_alert(self, f):
233235
else:
234236
break
235237

236-
def get_test_window(self, window_id, parent, timeout=5):
237-
"""Find the test window amongst all the open windows.
238-
This is assumed to be either the named window or the one after the parent in the list of
239-
window handles
240-
241-
:param window_id: The DOM name of the Window
242-
:param parent: The handle of the runner window
243-
:param timeout: The time in seconds to wait for the window to appear. This is because in
244-
some implementations there's a race between calling window.open and the
245-
window being added to the list of WebDriver accessible windows."""
246-
test_window = None
247-
end_time = time.time() + timeout
248-
while time.time() < end_time:
249-
if window_id:
250-
try:
251-
# Try this, it's in Level 1 but nothing supports it yet
252-
win_s = self.parent.base.execute_script("return window['%s'];" % self.window_id)
253-
win_obj = json.loads(win_s)
254-
test_window = win_obj["window-fcc6-11e5-b4f8-330a88ab9d7f"]
255-
except Exception:
256-
pass
257-
258-
if test_window is None:
259-
handles = self.marionette.window_handles
260-
if len(handles) == 2:
261-
test_window = next(iter(set(handles) - {parent}))
262-
elif len(handles) > 2 and handles[0] == parent:
263-
# Hope the first one here is the test window
264-
test_window = handles[1]
265-
266-
if test_window is not None:
267-
assert test_window != parent
268-
return test_window
269-
270-
time.sleep(0.1)
271-
272-
raise Exception("unable to find test window")
273-
274-
def test_window_loaded(self):
275-
"""Wait until the page in the new window has been loaded.
276-
277-
Hereby ignore Javascript execptions that are thrown when
278-
the document has been unloaded due to a process change.
279-
"""
280-
while True:
281-
try:
282-
self.parent.base.execute_script(self.window_loaded_script, asynchronous=True)
283-
break
284-
except errors.JavascriptException:
285-
pass
286-
287238

288239
class MarionettePrefsProtocolPart(PrefsProtocolPart):
289240
def setup(self):
@@ -496,7 +447,8 @@ def minimize(self):
496447
return self.marionette.minimize_window()
497448

498449
def set_rect(self, rect):
499-
self.marionette.set_window_rect(rect["x"], rect["y"], rect["height"], rect["width"])
450+
self.marionette.set_window_rect(
451+
rect.get("x"), rect.get("y"), rect.get("height"), rect.get("width"))
500452

501453
def get_rect(self):
502454
return self.marionette.window_rect
@@ -986,16 +938,13 @@ def do_test(self, test):
986938
return (test.make_result(extra=extra, *data), [])
987939

988940
def do_testharness(self, protocol, url, timeout):
989-
parent_window = protocol.testharness.close_old_windows(self.last_environment["protocol"])
941+
protocol.testharness.close_old_windows(self.last_environment["protocol"])
990942

991943
if self.protocol.coverage.is_enabled:
992944
self.protocol.coverage.reset()
993945

994-
protocol.base.execute_script("window.open('about:blank', '%s', 'noopener')" % self.window_id)
995-
test_window = protocol.testharness.get_test_window(self.window_id, parent_window,
996-
timeout=10 * self.timeout_multiplier)
946+
test_window = protocol.base.create_window()
997947
self.protocol.base.set_window(test_window)
998-
protocol.testharness.test_window_loaded()
999948

1000949
if self.debug_test and self.browser.supports_devtools:
1001950
self.protocol.debug.load_devtools()
@@ -1059,8 +1008,6 @@ def __init__(self, logger, browser, server_config, timeout_multiplier=1,
10591008

10601009
self.install_extensions = browser.extensions
10611010

1062-
with open(os.path.join(here, "reftest.js")) as f:
1063-
self.script = f.read()
10641011
with open(os.path.join(here, "test-wait.js")) as f:
10651012
self.wait_script = f.read() % {"classname": "reftest-wait"}
10661013

@@ -1108,10 +1055,19 @@ def do_test(self, test):
11081055
self.has_window = False
11091056

11101057
if not self.has_window:
1111-
self.protocol.base.execute_script(self.script)
1112-
self.protocol.base.set_window(self.protocol.marionette.window_handles[-1])
1058+
self.protocol.base.create_window(type="window")
1059+
# Resize the browser window so that its inner dimensions have
1060+
# exactly a size of 800x600 pixels, which means ignoring all
1061+
# visible toolbars and sidebars.
1062+
offsets = self.protocol.marionette.execute_script("""
1063+
return {
1064+
width: window.outerWidth - window.innerWidth,
1065+
height: window.outerHeight - window.innerHeight,
1066+
};
1067+
""")
1068+
self.protocol.marionette.set_window_rect(
1069+
x=0, y=0, width=800 + offsets["width"], height=600 + offsets["height"])
11131070
self.has_window = True
1114-
self.protocol.testharness.test_window_loaded()
11151071

11161072
if self.protocol.coverage.is_enabled:
11171073
self.protocol.coverage.reset()

testing/web-platform/tests/tools/wptrunner/wptrunner/executors/protocol.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ def wait(self):
150150
:returns: True to re-run the test, or False to continue with the next test"""
151151
pass
152152

153+
@abstractmethod
154+
def create_window(self, type="tab", **kwargs):
155+
"""Return a handle identifying a freshly created top level browsing context
156+
157+
:param type: - Type hint, either "tab" or "window"
158+
:returns: A protocol-specific handle"""
159+
pass
160+
153161
@property
154162
def current_window(self):
155163
"""Return a handle identifying the current top level browsing context
@@ -202,18 +210,6 @@ def close_old_windows(self, url_protocol):
202210
"""
203211
pass
204212

205-
@abstractmethod
206-
def get_test_window(self, window_id, parent):
207-
"""Get the window handle dorresponding to the window containing the
208-
currently active test.
209-
210-
:param window_id: A string containing the DOM name of the Window that
211-
contains the test, or None.
212-
:param parent: The handle of the runner window.
213-
:returns: A protocol-specific window handle.
214-
"""
215-
pass
216-
217213
@abstractmethod
218214
def test_window_loaded(self):
219215
"""Wait until the newly opened test window has been loaded."""

0 commit comments

Comments
 (0)