Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: LayoutTests/fast/media/media-query-list-listener.html

Issue 396283004: Make the MediaQueryList listener an EventListener (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/media/media-query-list-listener-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script> 2 <script src="../../resources/js-test.js"></script>
3 3
4 <div id="sandbox"></div> 4 <div id="sandbox"></div>
5 5
6 <script> 6 <script>
7 description("Media query listeners should fire on changes to matches status. "); 7 description("Media query listeners should fire on changes to matches status. ");
8 var jsTestIsAsync = true; 8 var jsTestIsAsync = true;
9 9
10 var sandbox = document.getElementById("sandbox"); 10 var sandbox = document.getElementById("sandbox");
11 var iframe = document.createElement("iframe"); 11 var iframe = document.createElement("iframe");
12 sandbox.appendChild(iframe); 12 sandbox.appendChild(iframe);
13 13
14 var matchMedia = iframe.contentWindow.matchMedia; 14 var matchMedia = iframe.contentWindow.matchMedia;
15 var mediaList = matchMedia("(max-width: 100px)"); 15 var mediaList = matchMedia("(max-width: 100px)");
16 var expectedValue = ""; 16 var expectedValue = "";
17 17
18 var tests = []; 18 var tests = [];
19 var currentTest = 0; 19 var currentTest = 0;
20 function runNextTest() { 20 function runNextTest() {
21 tests[currentTest++](); 21 tests[currentTest++]();
22 } 22 }
23 function listener(list) { 23 function listener(list) {
24 window.mediaListArgument = list; 24 window.mediaListArgument = list;
25 shouldBe("mediaList", "mediaListArgument"); 25 shouldBe("mediaList.matches", "mediaListArgument.matches");
26 shouldBe("mediaList.media", "mediaListArgument.media");
26 shouldBe("mediaList.matches", expectedValue); 27 shouldBe("mediaList.matches", expectedValue);
27 runNextTest(); 28 runNextTest();
28 } 29 }
29 30
30 mediaList.addListener(listener); 31 mediaList.addListener(listener);
31 32
32 shouldBe("mediaList.matches", "true"); 33 shouldBe("mediaList.matches", "true");
33 34
34 // Should fire. 35 // Should fire.
35 iframe.style.width = "200px"; 36 iframe.style.width = "200px";
(...skipping 16 matching lines...) Expand all
52 tests.push(function() { 53 tests.push(function() {
53 // Should not fire. 54 // Should not fire.
54 mediaList.removeListener(listener); 55 mediaList.removeListener(listener);
55 iframe.style.width = "200px"; 56 iframe.style.width = "200px";
56 iframe.offsetTop; 57 iframe.offsetTop;
57 shouldBe("mediaList.matches", "false"); 58 shouldBe("mediaList.matches", "false");
58 59
59 setTimeout(finishJSTest, 20); 60 setTimeout(finishJSTest, 20);
60 }); 61 });
61 </script> 62 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/media/media-query-list-listener-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698