toolkit/devtools/tests/unit/head_devtools.js

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 "use strict";
     2 const Cc = Components.classes;
     3 const Ci = Components.interfaces;
     4 const Cu = Components.utils;
     5 const Cr = Components.results;
     7 Cu.import("resource://gre/modules/devtools/Loader.jsm");
     8 Cu.import("resource://gre/modules/devtools/DevToolsUtils.jsm");
    10 // Register a console listener, so console messages don't just disappear
    11 // into the ether.
    12 let errorCount = 0;
    13 let listener = {
    14   observe: function (aMessage) {
    15     errorCount++;
    16     try {
    17       // If we've been given an nsIScriptError, then we can print out
    18       // something nicely formatted, for tools like Emacs to pick up.
    19       var scriptError = aMessage.QueryInterface(Ci.nsIScriptError);
    20       dump(aMessage.sourceName + ":" + aMessage.lineNumber + ": " +
    21            scriptErrorFlagsToKind(aMessage.flags) + ": " +
    22            aMessage.errorMessage + "\n");
    23       var string = aMessage.errorMessage;
    24     } catch (x) {
    25       // Be a little paranoid with message, as the whole goal here is to lose
    26       // no information.
    27       try {
    28         var string = "" + aMessage.message;
    29       } catch (x) {
    30         var string = "<error converting error message to string>";
    31       }
    32     }
    34     // Make sure we exit all nested event loops so that the test can finish.
    35     while (DebuggerServer.xpcInspector.eventLoopNestLevel > 0) {
    36       DebuggerServer.xpcInspector.exitNestedEventLoop();
    37     }
    38     do_throw("head_dbg.js got console message: " + string + "\n");
    39   }
    40 };
    42 let consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
    43 consoleService.registerListener(listener);

mercurial