| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 | 3 |
| 4 <script src="../../http/tests/inspector/inspector-test.js"></script> | 4 <script src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></s
cript> |
| 5 | 5 |
| 6 <style> | 6 <style> |
| 7 body { | 7 body { |
| 8 margin: 0; | 8 margin: 0; |
| 9 min-height: 1000px; | 9 min-height: 1000px; |
| 10 } | 10 } |
| 11 </style> | 11 </style> |
| 12 | 12 |
| 13 <script> | 13 <script> |
| 14 function dumpMetrics() | 14 function dumpMetrics() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 function test() | 27 function test() |
| 28 { | 28 { |
| 29 function getPageMetrics(callback) | 29 function getPageMetrics(callback) |
| 30 { | 30 { |
| 31 InspectorTest.evaluateInPage("dumpMetrics()", parse); | 31 InspectorTest.evaluateInPage("dumpMetrics()", parse); |
| 32 | 32 |
| 33 function parse(json) | 33 function parse(json) |
| 34 { | 34 { |
| 35 callback(JSON.parse(json.value)); | 35 callback(JSON.parse(json)); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 var initialMetrics; | 39 var initialMetrics; |
| 40 | 40 |
| 41 function testPartialOverride(name, value, next) | 41 function testPartialOverride(name, value, next) |
| 42 { | 42 { |
| 43 var params = {width: 0, height: 0, deviceScaleFactor: 0, mobile: false,
fitWindow: false}; | 43 var params = {width: 0, height: 0, deviceScaleFactor: 0, mobile: false,
fitWindow: false}; |
| 44 if (name === null) { | 44 if (name === null) { |
| 45 InspectorTest.PageAgent.clearDeviceMetricsOverride(getPageMetrics.bi
nd(null, check)); | 45 InspectorTest.sendCommandOrDie("Emulation.clearDeviceMetricsOverride
", {}, getPageMetrics.bind(null, check)); |
| 46 } else { | 46 } else { |
| 47 if (name) | 47 if (name) |
| 48 params[name] = value; | 48 params[name] = value; |
| 49 InspectorTest.PageAgent.invoke_setDeviceMetricsOverride(params, getP
ageMetrics.bind(null, check)); | 49 InspectorTest.sendCommandOrDie("Emulation.setDeviceMetricsOverride",
params, getPageMetrics.bind(null, check)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 function check(metrics) | 52 function check(metrics) |
| 53 { | 53 { |
| 54 var fail = false; | 54 var fail = false; |
| 55 for (var key in initialMetrics) { | 55 for (var key in initialMetrics) { |
| 56 var expected = key === name ? value : initialMetrics[key]; | 56 var expected = key === name ? value : initialMetrics[key]; |
| 57 if (metrics[key] !== expected) { | 57 if (metrics[key] !== expected) { |
| 58 InspectorTest.addResult("[FAIL]: " + metrics[key] + " instea
d of " + expected + " for " + key); | 58 InspectorTest.log("[FAIL]: " + metrics[key] + " instead of "
+ expected + " for " + key); |
| 59 fail = true; | 59 fail = true; |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 if (!fail) | 62 if (!fail) |
| 63 InspectorTest.addResult(name ? ("[PASS]: " + name + "=" + value)
: "[PASS]"); | 63 InspectorTest.log(name ? ("[PASS]: " + name + "=" + value) : "[P
ASS]"); |
| 64 next(); | 64 next(); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 InspectorTest.runTestSuite([ | 68 InspectorTest.runTestSuite([ |
| 69 function collectMetrics(next) | 69 function collectMetrics(next) |
| 70 { | 70 { |
| 71 function collect(metrics) | 71 function collect(metrics) |
| 72 { | 72 { |
| 73 initialMetrics = metrics; | 73 initialMetrics = metrics; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 129 } |
| 130 </script> | 130 </script> |
| 131 | 131 |
| 132 </head> | 132 </head> |
| 133 <body onload="runTest()"> | 133 <body onload="runTest()"> |
| 134 <p> | 134 <p> |
| 135 Tests that overriding only a single parameter does not affect others. | 135 Tests that overriding only a single parameter does not affect others. |
| 136 </p> | 136 </p> |
| 137 </body> | 137 </body> |
| 138 </html> | 138 </html> |
| OLD | NEW |