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

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

Issue 347423010: Add a test for matchMedia listeners. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3
4 <div id="sandbox"></div>
5
6 <script>
7 description("Media query listeners should fire on changes to matches status. ");
8
9 if (window.testRunner)
10 testRunner.dumpAsText();
11
12 var sandbox = document.getElementById("sandbox");
13 var iframe = document.createElement("iframe");
14 sandbox.appendChild(iframe);
15
16 var matchMedia = iframe.contentWindow.matchMedia;
17 var mediaList = matchMedia("(max-width: 100px)");
18 var expectedValue = "";
19
20 function listener(list) {
21 window.mediaListArgument = list;
22 shouldBe("mediaList", "mediaListArgument");
23 shouldBe("mediaList.matches", expectedValue);
24 }
25
26 mediaList.addListener(listener);
27
28 shouldBe("mediaList.matches", "true");
29
30 // FIXME: You shouldn't need to touch offsetTop to force these updates.
31
32 // Should fire.
33 iframe.style.width = "200px";
34 expectedValue = "false";
35 iframe.offsetTop;
36
37 // Should not fire.
38 iframe.style.width = "250px";
39 expectedValue = "false";
40 iframe.offsetTop;
41
42 // Should fire.
43 iframe.style.width = "80px";
44 expectedValue = "true";
45 iframe.offsetTop;
46
47 // Should not fire.
48 mediaList.removeListener(listener);
49 iframe.style.width = "200px";
50 iframe.offsetTop;
51 shouldBe("mediaList.matches", "false");
52 </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