toolkit/devtools/webconsole/test/test_page_errors.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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>
    14 <script class="testbody" type="text/javascript;version=1.8">
    15 SimpleTest.waitForExplicitFinish();
    17 let expectedPageErrors = [];
    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   ];
    44   let container = document.createElement("script");
    45   document.body.appendChild(container);
    46   container.textContent = "document.body.style.color = 'fooColor';";
    47   document.body.removeChild(container);
    49   SimpleTest.expectUncaughtException();
    51   container = document.createElement("script");
    52   document.body.appendChild(container);
    53   container.textContent = "document.doTheImpossible();";
    54   document.body.removeChild(container);
    55 }
    57 function startTest()
    58 {
    59   removeEventListener("load", startTest);
    61   attachConsole(["PageError"], onAttach);
    62 }
    64 function onAttach(aState, aResponse)
    65 {
    66   onPageError = onPageError.bind(null, aState);
    67   aState.dbgClient.addListener("pageError", onPageError);
    68   doPageErrors();
    69 }
    71 let pageErrors = [];
    73 function onPageError(aState, aType, aPacket)
    74 {
    75   is(aPacket.from, aState.actor, "page error actor");
    77   pageErrors.push(aPacket.pageError);
    78   if (pageErrors.length != expectedPageErrors.length) {
    79     return;
    80   }
    82   aState.dbgClient.removeListener("pageError", onPageError);
    84   expectedPageErrors.forEach(function(aMessage, aIndex) {
    85     info("checking received page error #" + aIndex);
    86     checkObject(pageErrors[aIndex], expectedPageErrors[aIndex]);
    87   });
    89   closeDebugger(aState, function() {
    90     SimpleTest.finish();
    91   });
    92 }
    94 addEventListener("load", startTest);
    95 </script>
    96 </body>
    97 </html>

mercurial