Bug 1598648 [wpt PR 20401] - Add listeners per MQL storage test, a=testonly draft
authorAlexey Shvayka <shvaikalesh@gmail.com>
Fri, 22 Nov 2019 15:32:53 +0000
changeset 2496002 0541b7d3ee53ca182e5bf88e3dd56794f41b134d
parent 2496001 7ab0dcef6b352553c7a780e284810d5c2f37bde7
child 2496003 c3c5e3fe72f8a1c98853770ddf4f7f1204f77bfa
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] - Add listeners per MQL storage test, a=testonly wpt-commit: 8c6983393ed9271e415276f324761dbf517ccaf5 wpt-pr: 20401
testing/web-platform/tests/css/cssom-view/MediaQueryList-addListener-removeListener.html
--- a/testing/web-platform/tests/css/cssom-view/MediaQueryList-addListener-removeListener.html
+++ b/testing/web-platform/tests/css/cssom-view/MediaQueryList-addListener-removeListener.html
@@ -113,16 +113,37 @@ promise_test(async t => {
 
     iframe.width = "200"; // 100x100 => 200x100
     await waitForChangesReported();
 
     assert_equals(calls.join(), "mql1,mql2");
 }, "listeners are called in order their MQLs were created");
 
 promise_test(async t => {
+    const iframe = await createIFrame(t, 200);
+    const media = `(max-height: 150px)`;
+
+    const mql1 = iframe.contentWindow.matchMedia(media);
+    const mql2 = iframe.contentWindow.matchMedia(media);
+
+    let calls = 0;
+    const listener = () => {
+        calls++;
+    };
+
+    mql1.addListener(listener);
+    mql2.removeListener(listener);
+
+    iframe.height = "50"; // 200x200 => 200x50
+    await waitForChangesReported();
+
+    assert_equals(calls, 1);
+}, "removing listener from one MQL doesn't remove it from all MQLs");
+
+promise_test(async t => {
     const mql = await createMQL(t);
     const listener = t.unreached_func("should not be called");
 
     mql.addListener(listener);
     mql.removeListener(listener);
 
     triggerMQLEvent(mql);
     await waitForChangesReported();