Bug 1598648 [wpt PR 20401] - Fix MediaQueryListEvent `instanceof` tests, a=testonly draft
authorAlexey Shvayka <shvaikalesh@gmail.com>
Sat, 23 Nov 2019 09:18:04 +0000
changeset 2496007 931419f26849430ac4d2db3b0dd44bf74427a3da
parent 2496006 d557575e238b751050f225b02732b1ef0dc40094
child 2496008 2867fdb8695ed49b7723518d328426bbb33fc387
push id455263
push userwptsync@mozilla.com
push dateMon, 25 Nov 2019 19:36:14 +0000
treeherdertry@e7eb01746159 [default view] [failures only]
reviewerstestonly
bugs1598648, 20401
milestone72.0a1
Bug 1598648 [wpt PR 20401] - Fix MediaQueryListEvent `instanceof` tests, a=testonly wpt-commit: 2c00109775596dc6b8a644c8ac48f55eeebd3d69 wpt-pr: 20401
testing/web-platform/tests/css/cssom-view/MediaQueryListEvent.html
testing/web-platform/tests/css/cssom-view/resources/matchMedia.js
--- a/testing/web-platform/tests/css/cssom-view/MediaQueryListEvent.html
+++ b/testing/web-platform/tests/css/cssom-view/MediaQueryListEvent.html
@@ -43,48 +43,48 @@ promise_test(async t => {
     let _event;
     mql.addListener(event => {
         _event = event;
     });
 
     triggerMQLEvent(mql);
     await waitForChangesReported();
 
-    assert_true(_event instanceof MediaQueryListEvent);
+    assert_true(_event instanceof getWindow(mql).MediaQueryListEvent);
     assert_equals(_event.type, "change");
     assert_false(_event.bubbles);
     assert_false(_event.cancelable);
 }, "argument of addListener");
 
 promise_test(async t => {
     const mql = await createMQL(t);
 
     let _event;
     mql.onchange = event => {
         _event = event;
     };
 
     triggerMQLEvent(mql);
     await waitForChangesReported();
 
-    assert_true(_event instanceof MediaQueryListEvent);
+    assert_true(_event instanceof getWindow(mql).MediaQueryListEvent);
     assert_equals(_event.type, "change");
     assert_false(_event.bubbles);
     assert_false(_event.cancelable);
 }, "argument of onchange");
 
 promise_test(async t => {
     const mql = await createMQL(t);
 
     let _event;
     mql.addEventListener("change", event => {
         _event = event;
     });
 
     triggerMQLEvent(mql);
     await waitForChangesReported();
 
-    assert_true(_event instanceof MediaQueryListEvent);
+    assert_true(_event instanceof getWindow(mql).MediaQueryListEvent);
     assert_equals(_event.type, "change");
     assert_false(_event.bubbles);
     assert_false(_event.cancelable);
 }, 'constructor of "change" event');
 </script>
--- a/testing/web-platform/tests/css/cssom-view/resources/matchMedia.js
+++ b/testing/web-platform/tests/css/cssom-view/resources/matchMedia.js
@@ -38,15 +38,21 @@ var createIFrame = (t, width = IFRAME_DE
 };
 
 var triggerMQLEvent = mql => {
     const iframe = iframes.get(mql);
     assert_not_equals(iframe, undefined, "Passed MQL instance was not created with createMQL");
     iframe.width = iframe.width === IFRAME_DEFAULT_SIZE ? "250" : IFRAME_DEFAULT_SIZE;
 };
 
+var getWindow = mql => {
+    const iframe = iframes.get(mql);
+    assert_not_equals(iframe, undefined, "Passed MQL instance was not created with createMQL");
+    return iframe.contentWindow;
+};
+
 var waitForChangesReported = () => {
     return new Promise(resolve => {
         step_timeout(resolve, 75);
     });
 };
 
 }