| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../http/tests/inspector/inspector-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 | 5 |
| 6 var windowOrientationChangeEvent = false; | 6 if (!window.testRunner) |
| 7 var screenOrientationChangeEvent = false; | 7 debug("This test requires testRunner"); |
| 8 | |
| 9 window.addEventListener("orientationchange", function() { windowOrientationChang
eEvent = true; maybeLog(); }); | |
| 10 screen.orientation.addEventListener("change", function() { screenOrientationChan
geEvent = true; maybeLog(); }); | |
| 11 | 8 |
| 12 function dump() | 9 function dump() |
| 13 { | 10 { |
| 14 return "angle: " + screen.orientation.angle + "; type: " + screen.orientatio
n.type; | 11 return "angle: " + screen.orientation.angle + "; type: " + screen.orientatio
n.type; |
| 15 } | 12 } |
| 16 | 13 |
| 17 function maybeLog() | 14 if (window.testRunner) |
| 18 { | 15 testRunner.setMockScreenOrientation("landscape-primary"); |
| 19 if (windowOrientationChangeEvent && screenOrientationChangeEvent) { | |
| 20 windowOrientationChangeEvent = false; | |
| 21 screenOrientationChangeEvent = false; | |
| 22 console.log(dump()); | |
| 23 } | |
| 24 } | |
| 25 | 16 |
| 26 function test() | 17 function test() |
| 27 { | 18 { |
| 28 function addDumpResult(next) | 19 function addDumpResult(next) |
| 29 { | 20 { |
| 30 InspectorTest.evaluateInPage("dump()", dumpCallback); | 21 InspectorTest.evaluateInPage("dump()", dumpCallback); |
| 31 | 22 |
| 32 function dumpCallback(result) | 23 function dumpCallback(result) |
| 33 { | 24 { |
| 34 InspectorTest.addResult(result.value); | 25 InspectorTest.addResult(result.value); |
| 35 next(); | 26 next(); |
| 36 } | 27 } |
| 37 } | 28 } |
| 38 | 29 |
| 39 function testOverride(angle, orientation, next) | 30 function testOverride(angle, orientation, next) |
| 40 { | 31 { |
| 41 InspectorTest.addConsoleSniffer(addDumpResult.bind(null, next)); | 32 var protocolCallback = addDumpResult.bind(null, next); |
| 42 InspectorTest.EmulationAgent.invoke_setDeviceMetricsOverride({width: 0,
height: 0, deviceScaleFactor: 0, mobile: true, fitWindow: false, screenOrientati
on: {type: orientation, angle: angle}}, function() {}); | 33 if (orientation) { |
| 34 InspectorTest.ScreenOrientationAgent.setScreenOrientationOverride(ang
le, orientation, protocolCallback); |
| 35 } else { |
| 36 InspectorTest.ScreenOrientationAgent.clearScreenOrientationOverride(
protocolCallback); |
| 37 } |
| 43 } | 38 } |
| 44 | 39 |
| 45 function testError(angle, orientation, next) | 40 function testError(angle, orientation, next) |
| 46 { | 41 { |
| 47 InspectorTest.EmulationAgent.invoke_setDeviceMetricsOverride({width: 0,
height: 0, deviceScaleFactor: 0, mobile: true, fitWindow: false, screenOrientati
on: {type: orientation, angle: angle}}, next); | 42 InspectorTest.ScreenOrientationAgent.setScreenOrientationOverride(angle,
orientation, protocolCallback); |
| 43 |
| 44 function protocolCallback(error) |
| 45 { |
| 46 InspectorTest.addResult(error); |
| 47 next(); |
| 48 } |
| 48 } | 49 } |
| 49 | 50 |
| 50 var original; | |
| 51 | |
| 52 InspectorTest.runTestSuite([ | 51 InspectorTest.runTestSuite([ |
| 53 function initial(next) | 52 function initial(next) |
| 54 { | 53 { |
| 55 InspectorTest.evaluateInPage("dump()", dumpCallback); | 54 addDumpResult(next); |
| 56 | |
| 57 function dumpCallback(result) | |
| 58 { | |
| 59 original = result.value; | |
| 60 next(); | |
| 61 } | |
| 62 }, | 55 }, |
| 63 | 56 |
| 64 function setWrongAngle1(next) | 57 function setWrongAngle1(next) |
| 65 { | 58 { |
| 66 testError(-1, "portraitPrimary", next); | 59 testError(-1, "portraitPrimary", next); |
| 67 }, | 60 }, |
| 68 | 61 |
| 69 function setWrongAngle2(next) | 62 function setWrongAngle2(next) |
| 70 { | 63 { |
| 71 testError(360, "portraitPrimary", next); | 64 testError(360, "portraitPrimary", next); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 96 InspectorTest.reloadPage(addDumpResult.bind(null, next)); | 89 InspectorTest.reloadPage(addDumpResult.bind(null, next)); |
| 97 }, | 90 }, |
| 98 | 91 |
| 99 function setLandscapeSecondary(next) | 92 function setLandscapeSecondary(next) |
| 100 { | 93 { |
| 101 testOverride(270, "landscapeSecondary", next); | 94 testOverride(270, "landscapeSecondary", next); |
| 102 }, | 95 }, |
| 103 | 96 |
| 104 function clearOverride(next) | 97 function clearOverride(next) |
| 105 { | 98 { |
| 106 InspectorTest.EmulationAgent.clearDeviceMetricsOverride(checkInitial
); | 99 testOverride(0, "", next); |
| 107 | |
| 108 function checkInitial() | |
| 109 { | |
| 110 InspectorTest.evaluateInPage("dump()", dumpCallback); | |
| 111 } | |
| 112 | |
| 113 function dumpCallback(result) | |
| 114 { | |
| 115 InspectorTest.addResult("Equals to initial: " + (original === re
sult.value ? "true" : "false")); | |
| 116 next(); | |
| 117 } | |
| 118 } | 100 } |
| 119 ]); | 101 ]); |
| 120 } | 102 } |
| 121 </script> | 103 </script> |
| 122 </head> | 104 </head> |
| 123 <body onload="runTest()"> | 105 <body onload="runTest()"> |
| 124 <p> | 106 <p> |
| 125 </p> | 107 </p> |
| 126 </body> | 108 </body> |
| 127 </html> | 109 </html> |
| OLD | NEW |