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