|
1 <!DOCTYPE HTML> |
|
2 <html lang="en"> |
|
3 <head> |
|
4 <meta charset="utf8"> |
|
5 <title>Test for page errors</title> |
|
6 <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
7 <script type="text/javascript;version=1.8" src="common.js"></script> |
|
8 <!-- Any copyright is dedicated to the Public Domain. |
|
9 - http://creativecommons.org/publicdomain/zero/1.0/ --> |
|
10 </head> |
|
11 <body> |
|
12 <p>Test for page errors</p> |
|
13 |
|
14 <script class="testbody" type="text/javascript;version=1.8"> |
|
15 SimpleTest.waitForExplicitFinish(); |
|
16 |
|
17 let expectedPageErrors = []; |
|
18 |
|
19 function doPageErrors() |
|
20 { |
|
21 expectedPageErrors = [ |
|
22 { |
|
23 errorMessage: /fooColor/, |
|
24 sourceName: /test_page_errors/, |
|
25 category: "CSS Parser", |
|
26 timeStamp: /^\d+$/, |
|
27 error: false, |
|
28 warning: true, |
|
29 exception: false, |
|
30 strict: false, |
|
31 }, |
|
32 { |
|
33 errorMessage: /doTheImpossible/, |
|
34 sourceName: /test_page_errors/, |
|
35 category: "chrome javascript", |
|
36 timeStamp: /^\d+$/, |
|
37 error: false, |
|
38 warning: false, |
|
39 exception: true, |
|
40 strict: false, |
|
41 }, |
|
42 ]; |
|
43 |
|
44 let container = document.createElement("script"); |
|
45 document.body.appendChild(container); |
|
46 container.textContent = "document.body.style.color = 'fooColor';"; |
|
47 document.body.removeChild(container); |
|
48 |
|
49 SimpleTest.expectUncaughtException(); |
|
50 |
|
51 container = document.createElement("script"); |
|
52 document.body.appendChild(container); |
|
53 container.textContent = "document.doTheImpossible();"; |
|
54 document.body.removeChild(container); |
|
55 } |
|
56 |
|
57 function startTest() |
|
58 { |
|
59 removeEventListener("load", startTest); |
|
60 |
|
61 attachConsole(["PageError"], onAttach); |
|
62 } |
|
63 |
|
64 function onAttach(aState, aResponse) |
|
65 { |
|
66 onPageError = onPageError.bind(null, aState); |
|
67 aState.dbgClient.addListener("pageError", onPageError); |
|
68 doPageErrors(); |
|
69 } |
|
70 |
|
71 let pageErrors = []; |
|
72 |
|
73 function onPageError(aState, aType, aPacket) |
|
74 { |
|
75 is(aPacket.from, aState.actor, "page error actor"); |
|
76 |
|
77 pageErrors.push(aPacket.pageError); |
|
78 if (pageErrors.length != expectedPageErrors.length) { |
|
79 return; |
|
80 } |
|
81 |
|
82 aState.dbgClient.removeListener("pageError", onPageError); |
|
83 |
|
84 expectedPageErrors.forEach(function(aMessage, aIndex) { |
|
85 info("checking received page error #" + aIndex); |
|
86 checkObject(pageErrors[aIndex], expectedPageErrors[aIndex]); |
|
87 }); |
|
88 |
|
89 closeDebugger(aState, function() { |
|
90 SimpleTest.finish(); |
|
91 }); |
|
92 } |
|
93 |
|
94 addEventListener("load", startTest); |
|
95 </script> |
|
96 </body> |
|
97 </html> |