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

Side by Side Diff: LayoutTests/inspector/styles/override-screen-size.html

Issue 23187005: [DevTools] Use device metrics emulation implemented in content. (Closed) Base URL: svn://svn.chromium.org/blink/trunk/
Patch Set: Another rebase Created 7 years, 2 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
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 3
4 <style type="text/css" media="screen"> 4 <style type="text/css" media="screen">
5 @media (max-device-width: 478px) and (max-device-height: 959px) { 5 @media (max-device-width: 478px) and (max-device-height: 799px) {
6 #main { background: red; } 6 #main { background: red; }
7 } 7 }
8 8
9 @media (max-device-width: 480px) and (max-device-height: 960px) { 9 @media (max-device-width: 480px) and (max-device-height: 800px) {
10 #main { background: green; } 10 #main { background: green; }
11 } 11 }
12 12
13 @media (min-device-width: 481px) and (min-device-height: 961px) { 13 @media (min-device-width: 481px) and (min-device-height: 801px) {
14 #main { background: yellow; } 14 #main { background: yellow; }
15 } 15 }
16 16
17 body { 17 body {
18 position: absolute; 18 position: absolute;
19 top: 0; 19 top: 0;
20 right: 0; 20 right: 0;
21 bottom: 0; 21 bottom: 0;
22 left: 0; 22 left: 0;
23 margin: 0; 23 margin: 0;
(...skipping 11 matching lines...) Expand all
35 return JSON.stringify({ 35 return JSON.stringify({
36 screen: window.screen.width + "x" + window.screen.height, 36 screen: window.screen.width + "x" + window.screen.height,
37 inner: window.innerWidth + "x" + window.innerHeight, 37 inner: window.innerWidth + "x" + window.innerHeight,
38 body: document.body.offsetWidth + "x" + document.body.offsetHeight 38 body: document.body.offsetWidth + "x" + document.body.offsetHeight
39 }); 39 });
40 } 40 }
41 41
42 function test() 42 function test()
43 { 43 {
44 var exceededDimension = 10000001; 44 var exceededDimension = 10000001;
45 var overridesEnabled = false;
45 var originalScreenSize; 46 var originalScreenSize;
46 47
47 function saveSizeCallback(jsonResult) 48 function saveSizeCallback(jsonResult)
48 { 49 {
49 var value = JSON.parse(jsonResult.value); 50 var value = JSON.parse(jsonResult.value);
50 originalScreenSize = value.screen; 51 originalScreenSize = value.screen;
51 if (!originalScreenSize || originalScreenSize.indexOf("x") === -1) 52 if (!originalScreenSize || originalScreenSize.indexOf("x") === -1)
52 InspectorTest.addResult("Invalid original screen size: " + originalS creenSize + ". Expect runtime failures later on."); 53 InspectorTest.addResult("Invalid original screen size: " + originalS creenSize + ". Expect runtime failures later on.");
53 54
54 InspectorTest.selectNodeAndWaitForStyles("main", step0); 55 InspectorTest.selectNodeAndWaitForStyles("main", step0);
55 } 56 }
56 57
57 InspectorTest.evaluateInPage("getSizes()", saveSizeCallback); 58 InspectorTest.evaluateInPage("getSizes()", saveSizeCallback);
58 59
59 60
60 function step0() 61 function step0()
61 { 62 {
62 overrideAndDumpData(480, 800, step1); 63 overrideAndDumpData(480, 800, step1);
63 } 64 }
64 65
65 function step1() 66 function step1()
66 { 67 {
68 overrideAndDumpData(800, 480, step2);
69 }
70
71 function step2()
72 {
73 applyOverride(exceededDimension, 800, step3);
74 }
75
76 function step3()
77 {
78 applyOverride(-1, 800, step4);
79 }
80
81 function step4()
82 {
83 applyOverride(480, exceededDimension, step5);
84 }
85
86 function step5()
87 {
88 function callback()
89 {
90 InspectorTest.addResult("Current dimensions:");
91 getAndDumpSizes(step6);
92 }
93 applyOverride(480, -1, callback);
94 }
95
96 function step6()
97 {
67 function compareSizeCallback(jsonResult) 98 function compareSizeCallback(jsonResult)
68 { 99 {
69 // Check that the screen size reported is the same as the original o ne. 100 // Check that the screen size reported is the same as the original o ne.
70 var result = JSON.parse(jsonResult.value); 101 var result = JSON.parse(jsonResult.value);
71 if (result.screen !== originalScreenSize) 102 if (result.screen !== originalScreenSize)
72 InspectorTest.addResult("Original size " + originalScreenSize + " not restored, found: " + result.screen); 103 InspectorTest.addResult("Original size " + originalScreenSize + " not restored, found: " + result.screen);
73 step2(); 104 InspectorTest.completeTest();
74 } 105 }
75 106
76 function overrideCallback() 107 function overrideCallback()
77 { 108 {
78 InspectorTest.evaluateInPage("getSizes()", compareSizeCallback); 109 InspectorTest.evaluateInPage("getSizes()", compareSizeCallback);
79 } 110 }
80 111
81 // Disable overrides. 112 // Disable overrides.
82 PageAgent.setDeviceMetricsOverride(0, 0, 1, true, overrideCallback); 113 applyOverride(0, 0, overrideCallback);
83 }
84
85 function step2()
86 {
87 overrideAndDumpData(800, 480, step3);
88 }
89
90 function step3()
91 {
92 applyOverride(exceededDimension, 800, step4);
93 }
94
95 function step4()
96 {
97 applyOverride(-1, 800, step5);
98 }
99
100 function step5()
101 {
102 applyOverride(480, exceededDimension, step6);
103 }
104
105 function step6()
106 {
107 function callback()
108 {
109 InspectorTest.addResult("Current dimensions:");
110 getAndDumpSizes(step7);
111 }
112 applyOverride(480, -1, callback);
113 }
114
115 function step7()
116 {
117 function callback(jsonResult)
118 {
119 var value = JSON.parse(jsonResult.value);
120 if (value.screen !== originalScreenSize)
121 InspectorTest.addResult("Screen size not restored, actual: " + v alue.screen + ", expected: " + originalScreenSize);
122 else
123 InspectorTest.addResult("Screen size same as original - OK");
124 step8();
125 }
126
127 InspectorTest.addResult("Disable PageAgent:");
128 PageAgent.disable();
129 InspectorTest.evaluateInPage("getSizes()", callback);
130 }
131
132 function step8()
133 {
134 function callback(jsonResult)
135 {
136 var value = JSON.parse(jsonResult.value);
137 if (value.screen !== originalScreenSize)
138 InspectorTest.addResult("Screen size not restored, actual: " + v alue.screen + ", expected: " + originalScreenSize);
139 else
140 InspectorTest.addResult("Screen size same as original - OK");
141 InspectorTest.completeTest();
142 }
143
144 InspectorTest.addResult("Enable PageAgent:");
145 PageAgent.enable();
146 InspectorTest.evaluateInPage("getSizes()", callback);
147 } 114 }
148 115
149 function applyOverride(width, height, userCallback) 116 function applyOverride(width, height, userCallback)
150 { 117 {
151 function callback(error) 118 function callback(reload, error)
152 { 119 {
153 if (error) 120 if (error)
154 InspectorTest.addResult("Override: " + width + "x" + height + " => ERROR"); 121 InspectorTest.addResult("Override: " + width + "x" + height + " => ERROR");
155 userCallback(); 122 if (reload && !error) {
123 InspectorTest.reloadPage(userCallback);
124 } else {
125 userCallback();
126 }
156 } 127 }
157 PageAgent.setDeviceMetricsOverride(width, height, 1, true, callback); 128
129 var enabled = width != 0 || height != 0;
130 PageAgent.setDeviceMetricsOverride(width, height, 1, true, callback.bind (null, enabled != overridesEnabled));
131 overridesEnabled = enabled;
158 } 132 }
159 133
160 function overrideAndDumpData(width, height, callback) 134 function overrideAndDumpData(width, height, callback)
161 { 135 {
162 function finalCallback() 136 function finalCallback()
163 { 137 {
164 InspectorTest.addResult("Main style:"); 138 InspectorTest.addResult("Main style:");
165 InspectorTest.dumpSelectedElementStyles(true, false, true); 139 InspectorTest.dumpSelectedElementStyles(true, false, true);
166 callback(); 140 callback();
167 } 141 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 </head> 185 </head>
212 186
213 <body onload="runTest()"> 187 <body onload="runTest()">
214 <p> 188 <p>
215 Tests that screen dimension overrides affect media rules, body dimensions, and w indow.screen. 189 Tests that screen dimension overrides affect media rules, body dimensions, and w indow.screen.
216 </p> 190 </p>
217 191
218 <div id="main"></div> 192 <div id="main"></div>
219 </body> 193 </body>
220 </html> 194 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698