Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector-protocol / css / media-query-listener-exception.html
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script>
5 if (window.testRunner) {
6     testRunner.dumpAsText();
7     testRunner.waitUntilDone();
8 }
9
10 var theMediaQueryList = window.matchMedia("print");
11
12 var callCount = 0;
13 theMediaQueryList.addListener(function(aMediaQueryList) {
14     ++callCount;
15     if (callCount == 1) {
16         // This needs to use setTimeout because we want to test
17         // uncaught exceptions.
18         setTimeout("evaluateInFrontend('InspectorTest.sendPageDisable()')", 0);
19     }
20     if (callCount == 2) {
21         // This needs to use setTimeout because we want to test
22         // uncaught exceptions.
23         setTimeout("evaluateInFrontend('InspectorTest.completeTest()')", 0);
24     }
25     objectThatDoesNotExist.produceError();
26 });
27
28 function test()
29 {
30     InspectorTest.sendPageDisable = function()
31     {
32         InspectorTest.sendCommand("Page.disable", {});
33     }
34
35     function didSetEmulatedMedia(messageObject)
36     {
37         if (messageObject.error)
38             InspectorTest.log("FAILED: " + messageObject.error.message);
39     }
40
41     InspectorTest.sendCommand("Page.enable", {});
42     InspectorTest.sendCommand("Page.setEmulatedMedia", {
43         "media": "print"
44     }, didSetEmulatedMedia);
45 }
46 </script>
47 </head>
48 <body onload="runTest()">
49 <p>Test that uncaught exception in MediaQueryListListener will be reported to the console. On success you should see two exceptions in the listener logged to the console (first time when the media type is overridden and second - when they are restored). <a href="https://bugs.webkit.org/show_bug.cgi?id=105162">Bug 105162.</p>
50 </body>
51 </html>