gecko/toolkit/components/console/hudservice/tests/browser/browser_webconsole_consoleonpage.js
Mihai Sucan 32fddea0fa Bug 580618: don't use weak references to hold on to hud objects, feedback=ddahl, r=gavin, a=blocking
--HG--
extra : rebase_source : a97e67792a6a4694065ab75e9b83de1516d1d0e9
2010-11-17 14:21:14 -05:00

51 lines
1.4 KiB
JavaScript

/* vim:set ts=2 sw=2 sts=2 et: */
/* ***** BEGIN LICENSE BLOCK *****
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*
* Contributor(s):
* Julian Viereck <jviereck@mozilla.com>
* Mihai Șucan <mihai.sucan@gmail.com>
*
* ***** END LICENSE BLOCK ***** */
const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-own-console.html";
function test()
{
addTab(TEST_URI);
browser.addEventListener("load", function() {
browser.removeEventListener("load", arguments.callee, true);
testOpenWebConsole();
}, true);
}
function testOpenWebConsole()
{
openConsole();
is(HUDService.displaysIndex().length, 1, "WebConsole was opened");
hudId = HUDService.displaysIndex()[0];
hud = HUDService.hudReferences[hudId];
testOwnConsole();
}
function testConsoleOnPage(console) {
isnot(console, undefined, "Console object defined on page");
is(console.foo, "bar", "Custom console is not overwritten");
}
function testOwnConsole()
{
let console = browser.contentWindow.wrappedJSObject.console;
// Test console on the page. There is already one so it shouldn't be
// overwritten by the WebConsole's console.
testConsoleOnPage(console);
// Check that the console object is set on the jsterm object although there
// is no console object added to the page.
ok(hud.jsterm.console, "JSTerm console is defined");
finishTest();
}