browser/devtools/webconsole/test/browser_webconsole_notifications.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* vim:set ts=2 sw=2 sts=2 et: */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 const TEST_URI = "data:text/html;charset=utf-8,<p>Web Console test for notifications";
michael@0 7
michael@0 8 function test() {
michael@0 9 observer.init();
michael@0 10 addTab(TEST_URI);
michael@0 11 browser.addEventListener("load", onLoad, true);
michael@0 12 }
michael@0 13
michael@0 14 function webConsoleCreated(aID)
michael@0 15 {
michael@0 16 Services.obs.removeObserver(observer, "web-console-created");
michael@0 17 ok(HUDService.getHudReferenceById(aID), "We have a hud reference");
michael@0 18 content.wrappedJSObject.console.log("adding a log message");
michael@0 19 }
michael@0 20
michael@0 21 function webConsoleDestroyed(aID)
michael@0 22 {
michael@0 23 Services.obs.removeObserver(observer, "web-console-destroyed");
michael@0 24 ok(!HUDService.getHudReferenceById(aID), "We do not have a hud reference");
michael@0 25 executeSoon(finishTest);
michael@0 26 }
michael@0 27
michael@0 28 function webConsoleMessage(aID, aNodeID)
michael@0 29 {
michael@0 30 Services.obs.removeObserver(observer, "web-console-message-created");
michael@0 31 ok(aID, "we have a console ID");
michael@0 32 is(typeof aNodeID, "string", "message node id is a string");
michael@0 33 executeSoon(closeConsole);
michael@0 34 }
michael@0 35
michael@0 36 let observer = {
michael@0 37
michael@0 38 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
michael@0 39
michael@0 40 observe: function observe(aSubject, aTopic, aData)
michael@0 41 {
michael@0 42 aSubject = aSubject.QueryInterface(Ci.nsISupportsString);
michael@0 43
michael@0 44 switch(aTopic) {
michael@0 45 case "web-console-created":
michael@0 46 webConsoleCreated(aSubject.data);
michael@0 47 break;
michael@0 48 case "web-console-destroyed":
michael@0 49 webConsoleDestroyed(aSubject.data);
michael@0 50 break;
michael@0 51 case "web-console-message-created":
michael@0 52 webConsoleMessage(aSubject, aData);
michael@0 53 break;
michael@0 54 default:
michael@0 55 break;
michael@0 56 }
michael@0 57 },
michael@0 58
michael@0 59 init: function init()
michael@0 60 {
michael@0 61 Services.obs.addObserver(this, "web-console-created", false);
michael@0 62 Services.obs.addObserver(this, "web-console-destroyed", false);
michael@0 63 Services.obs.addObserver(this, "web-console-message-created", false);
michael@0 64 }
michael@0 65 };
michael@0 66
michael@0 67 function onLoad() {
michael@0 68 browser.removeEventListener("load", onLoad, true);
michael@0 69 openConsole();
michael@0 70 }

mercurial