Bug 534398 - Implement Heads Up Display console, js workspaces and related tools (r=dietrich, r=mrbkap)

This commit is contained in:
ddahl@mozilla.com 2010-06-18 16:18:16 -07:00
parent d9be0d1283
commit 074dbc6c09
22 changed files with 4281 additions and 0 deletions

View File

@ -611,6 +611,11 @@
accesskey="&errorConsoleCmd.accesskey;"
key="key_errorConsole"
oncommand="toJavaScriptConsole();"/>
<menuitem id="headsUpDisplayConsole"
label="&hudConsoleCmd.label;"
accesskey="&hudConsoleCmd.accesskey;"
key="key_hudConsole"
oncommand="HUDConsoleUI.toggleHUD();"/>
<menuitem id="menu_pageInfo"
accesskey="&pageInfoCmd.accesskey;"
label="&pageInfoCmd.label;"

View File

@ -222,6 +222,7 @@
<key id="key_openDownloads" key="&downloads.commandkey;" command="Tools:Downloads" modifiers="accel"/>
#endif
<key id="key_errorConsole" key="&errorConsoleCmd.commandkey;" oncommand="toJavaScriptConsole();" modifiers="accel,shift"/>
<key id="key_hudConsole" key="&hudConsoleCmd.commandkey;" oncommand="HUDConsoleUI.toggleHUD();" modifiers="accel,shift"/>
<key id="key_inspect" key="&inspectMenu.commandkey;" command="Tools:Inspect" modifiers="accel,shift"/>
<key id="openFileKb" key="&openFileCmd.commandkey;" command="Browser:OpenFile" modifiers="accel"/>
<key id="key_savePage" key="&savePageCmd.commandkey;" command="Browser:SavePage" modifiers="accel"/>

View File

@ -7671,3 +7671,14 @@ var TabContextMenu = {
getClosedTabCount(window) == 0;
}
};
XPCOMUtils.defineLazyGetter(this, "HUDConsoleUI", function () {
Cu.import("resource://gre/modules/HUDService.jsm");
try {
return HUDService.consoleUI;
}
catch (ex) {
Components.utils.reportError(ex);
}
});

View File

@ -159,6 +159,10 @@
<!ENTITY errorConsoleCmd.accesskey "C">
<!ENTITY errorConsoleCmd.commandkey "j">
<!ENTITY hudConsoleCmd.label "Heads Up Display">
<!ENTITY hudConsoleCmd.accesskey "U">
<!ENTITY hudConsoleCmd.commandkey "k">
<!ENTITY inspectMenu.label "Inspect">
<!ENTITY inspectMenu.accesskey "T">
<!ENTITY inspectMenu.commandkey "I">

View File

@ -43,6 +43,9 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
PARALLEL_DIRS = hudservice \
$(NULL)
EXTRA_PP_COMPONENTS = jsconsole-clhandler.js
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,205 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is DevTools code
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* David Dahl <ddahl@mozilla.com>
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
.hud-box {
border-bottom: 1px solid #aaa;
}
.hud-outer-wrapper {
width: 100%;
height: 100%;
}
.hud-filter-btn > .toolbarbutton-icon { display: none; }
.hud-console-wrapper {
width: 100%;
overflow: auto;
max-height: 400px;
height: 400px;
}
.hud-main-label {
font-size: 1em;
padding-top: 0.33em;
font-weight: bold;
}
.hud-output-node div {
-moz-user-select: text;
}
.hud-output-node .hud-network {
color: blue;
}
.hud-output-node .hud-error {
color: red;
}
.hud-output-node .hud-log {
color: black;
}
.hud-output-node .hud-warn {
color: orange;
}
.hud-output-node .hud-info {
color: green;
}
.hud-output-node .hud-exception {
color: red; font-weight: bold;
}
.hud-hidden {
display: none;
}
.hud-msg-node {
width: 100%;
margin-top: 0.3em;
margin-bottom: 0.3em;
padding-left: 0.3em;
border-bottom: 1px solid #eee;
}
.hud-output-node {
height:380px;
max-height: 380px;
border-bottom: 1px solid #ddd;
border-top: 1px solid #ddd;
overflow-x: auto; overflow: auto;
font: 1em monospace; background-color: white;
width: 100%;
}
/* JSTerm Styles */
.jsterm-wrapper-node {
font-family: monospace;
font-size: 1em;
background-color: #000;
border: 1px solid #333;
padding: 0.1em;
width: 100%;
height: 400px;
}
.jsterm-output-node {
width: 100%;
height: 400px;
color: white;
background-color: black;
overflow: auto;
overflow-x: auto;
position: absolute;
-moz-box-direction: reverse;
}
.jsterm-output-node div {
-moz-user-select: text;
}
.jsterm-scroll-to-node {
height: 1px; width: 1px; position: relative; top: 92%; display: block;
}
.jsterm-input-node {
width: 98%;
font-family: monospace;
font-size: 1.2em;
line-height: 1.6em;
background-color: black;
color: white;
}
.jsterm-output-line {
font-size: 1.2em;
}
%include ../../../themes/pinstripe/global/shared.inc
toolbar[mode="text"] .toolbarbutton-text {
margin: 1px 2px !important;
}
toolbarbutton:hover:active,
toolbarbutton[open="true"] {
padding-top: 2px;
padding-bottom: 2px;
-moz-padding-start: 2px;
-moz-padding-end: 1px;
}
toolbarbutton[disabled="true"],
toolbarbutton[disabled="true"]:hover,
toolbarbutton[disabled="true"]:hover:active,
toolbarbutton[disabled="true"][open="true"] {
padding-top: 2px;
padding-bottom: 2px;
-moz-padding-start: 2px;
-moz-padding-end: 1px;
}
/* ..... checked state ..... */
toolbarbutton[checked="true"] {
border-color: ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow !important;
padding-top: 2px !important;
padding-bottom: 2px !important;
-moz-padding-start: 2px !important;
-moz-padding-end: 1px !important;
}
/* ..... unchecked state ..... */
toolbarbutton[checked="false"] {
padding-top: 2px !important;
padding-bottom: 2px !important;
-moz-padding-start: 2px !important;
-moz-padding-end: 1px !important;
}
toolbar {
padding: 1px 0px;
-moz-box-align: center;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is HUDService code.
#
# The Initial Developer of the Original Code is Mozilla Corporation.
#
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# David Dahl <ddahl@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = hudservice
EXTRA_JS_MODULES = HUDService.jsm \
$(NULL)
ifdef ENABLE_TESTS
DIRS += tests
endif
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,50 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is HUDService code.
#
# The Initial Developer of the Original Code is
# Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# David Dahl <ddahl@mozilla.com> (Original author)
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = test_hudservice
DIRS = browser
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,64 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is HUD test code.
#
# The Initial Developer of the Original Code is Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# David Dahl <ddahl@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = toolkit/components/console/hudservice/tests/browser
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_BROWSER_TEST_FILES = \
browser_HUDServiceTestsAll.js \
$(NULL)
_BROWSER_TEST_PAGES = \
test-console.html \
test-network.html \
test-mutation.html \
testscript.js \
test-filter.html \
test-observe-http-ajax.html \
test-data.json \
$(NULL)
libs:: $(_BROWSER_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
libs:: $(_BROWSER_TEST_PAGES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)

View File

@ -0,0 +1,423 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is DevTools test code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* David Dahl <ddahl@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "HUDService", function () {
Cu.import("resource://gre/modules/HUDService.jsm");
try {
return HUDService;
}
catch (ex) {
dump(ex + "\n");
}
});
let log = function _log(msg) {
dump("*** HUD Browser Test Log: " + msg + "\n");
};
const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console.html";
const TEST_HTTP_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-observe-http-ajax.html";
const TEST_NETWORK_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-network.html";
const TEST_FILTER_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-filter.html";
const TEST_MUTATION_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-mutation.html";
function noCacheUriSpec(aUriSpec) {
return aUriSpec + "?_=" + Date.now();
}
content.location.href = TEST_URI;
function testRegistries() {
var displaysIdx = HUDService.displaysIndex();
ok(displaysIdx.length == 1, "one display id found");
var display = displaysIdx[0];
var registry = HUDService.displayRegistry;
var uri = registry[display];
ok(registry[display], "we have a URI: " + registry[display]);
var uriRegistry = HUDService.uriRegistry;
ok(uriRegistry[uri].length == 1, "uri registry is working");
}
function testGetDisplayByURISpec() {
var outputNode = HUDService.getDisplayByURISpec(TEST_URI);
hudId = outputNode.getAttribute("id");
ok(hudId == HUDService.displaysIndex()[0], "outputNode fetched by URIspec");
}
function introspectLogNodes() {
var console =
tab.linkedBrowser.contentWindow.wrappedJSObject.console;
ok(console, "console exists");
console.log("I am a log message");
console.error("I am an error");
console.info("I am an info message");
console.warn("I am a warning message");
var len = HUDService.displaysIndex().length;
let id = HUDService.displaysIndex()[len - 1];
log("hudId:: " + id);
let hudBox = tab.ownerDocument.getElementById(id);
log("hudBox: " + hudBox);
let outputNode =
hudBox.querySelectorAll(".hud-output-node")[0];
log("childElementCount " + outputNode.childElementCount);
ok(outputNode.childElementCount > 0, "more than 1 child node");
let domLogEntries =
outputNode.childNodes;
let count = outputNode.childNodes.length;
ok(count > 0, "LogCount: " + count);
let klasses = ["hud-msg-node hud-log",
"hud-msg-node hud-warn",
"hud-msg-node hud-info",
"hud-msg-node hud-error",
"hud-msg-node hud-exception",
"hud-msg-node hud-network"];
function verifyClass(klass) {
let len = klasses.length;
for (var i = 0; i < len; i++) {
if (klass == klasses[i]) {
return true;
}
}
return false;
}
for (var i = 0; i < count; i++) {
let klass = domLogEntries[i].getAttribute("class");
ok(verifyClass(klass),
"Log Node class verified: " + klass);
}
}
function getAllHUDS() {
var allHuds = HUDService.displays();
ok(typeof allHuds == "object", "allHuds is an object");
var idx = HUDService.displaysIndex();
hudId = idx[0];
ok(typeof idx == "object", "displays is an object");
ok(typeof idx.push == "function", "displaysIndex is an array");
var len = idx.length;
ok(idx.length > 0, "idx.length > 0: " + len);
}
function testGetDisplayByLoadGroup() {
var outputNode = HUDService.getDisplayByURISpec(TEST_URI);
var hudId = outputNode.getAttribute("id");
log("test hudId: " + hudId);
var loadGroup = HUDService.getLoadGroup(hudId);
log("test loadGroup: " + loadGroup);
var display = HUDService.getDisplayByLoadGroup(loadGroup);
ok(display.getAttribute("id") == hudId, "got display by loadGroup");
content.location = TEST_HTTP_URI;
executeSoon(function () {
let id = HUDService.displaysIndex()[0];
log(id);
let domLogEntries =
outputNode.childNodes;
let count = outputNode.childNodes.length;
ok(count > 0, "LogCount: " + count);
let klasses = ["hud-network"];
function verifyClass(klass) {
let len = klasses.length;
for (var i = 0; i < len; i++) {
if (klass == klasses[i]) {
return true;
}
}
return false;
}
for (var i = 0; i < count; i++) {
let klass = domLogEntries[i].getAttribute("class");
if (klass != "hud-network") {
continue;
}
ok(verifyClass(klass),
"Log Node network class verified");
}
});
}
function testUnregister() {
HUDService.deactivateHUDForContext(tab);
ok(HUDService.displays()[0] == undefined,
"No heads up displays are registered");
HUDService.shutdown();
}
function getHUDById() {
let hud = HUDService.getHeadsUpDisplay(hudId);
ok(hud.getAttribute("id") == hudId, "found HUD node by Id.");
}
function testGetContentWindowFromHUDId() {
let window = HUDService.getContentWindowFromHUDId(hudId);
ok(window.document, "we have a contentWindow");
}
function testConsoleLoggingAPI(aMethod)
{
filterBox.value = "foo";
browser.contentWindow.wrappedJSObject.console[aMethod]("foo-bar-baz");
browser.contentWindow.wrappedJSObject.console[aMethod]("bar-baz");
var count = outputNode.querySelectorAll(".hud-hidden").length;
ok(count == 1, "1 hidden " + aMethod + " node found");
HUDService.clearDisplay(hudId);
// now toggle the current method off - make sure no visible message
// nodes are logged
filterBox.value = "";
HUDService.setFilterState(hudId, aMethod, false);
browser.contentWindow.wrappedJSObject.console[aMethod]("foo-bar-baz");
count = outputNode.querySelectorAll(".hud-hidden").length;
ok(count == 0, aMethod + " logging tunred off, 0 messages logged");
HUDService.clearDisplay(hudId);
}
function testLogEntry(aOutputNode, aMatchString, aSuccessErrObj)
{
executeSoon(function (){
var msgs = aOutputNode.childNodes;
for (var i = 0; i < msgs.length; i++) {
log(msgs[i].innerHTML);
var message = msgs[i].innerHTML.indexOf(aMatchString);
if (message > -1) {
ok(true, aSuccessErrObj.success);
return;
}
}
ok(false, aSuccessErrObj.err);
});
}
// test networking logging
function testNet()
{
HUDService.setFilterState(hudId, "network", true);
filterBox.value = "";
content.location = TEST_NETWORK_URI;
var successMsg =
"Found the loggged network message referencing a js file";
var errMsg = "Could not get logged network message for js file";
var display = HUDService.getHeadsUpDisplay(hudId);
// var outputNode = display.querySelectorAll(".hud-output-node")[0];
testLogEntry(outputNode,
"Network:", { success: successMsg, err: errMsg });
content.location.href = noCacheUriSpec(TEST_NETWORK_URI);
}
// test DOM Mutation logging
function testDOMMutation()
{
log("Testing DOMMutation!!!!");
HUDService.setFilterState(hudId, "mutation", true);
filterBox.value = "";
log("CONTENT: " + content);
content.location = TEST_MUTATION_URI;
executeSoon(function() {
content.wrappedJSObject.addEventListener("DOMContentLoaded",
function () {
log("*********** Mutation onload **************");
var successMsg = "Found Mutation Log Message";
var errMsg = "Could NOT find Mutation Log Message";
var display = HUDService.getHeadsUpDisplay(hudId);
var outputNode = display.querySelectorAll(".hud-output-node")[0];
testLogEntry(outputNode,
"Mutation", { success: successMsg, err: errMsg });
}, false);
content.location.href = TEST_NETWORK_URI;
});
}
function testCreateDisplay() {
ok(typeof cs.consoleDisplays == "object",
"consoledisplays exist");
ok(typeof cs.displayIndexes == "object",
"console indexes exist");
cs.createDisplay("foo");
ok(typeof cs.consoleDisplays["foo"] == "object",
"foo display exists");
ok(typeof cs.displayIndexes["foo"] == "object",
"foo index exists");
}
function testRecordEntry() {
var config = {
logLevel: "network",
message: "HumminaHummina!",
activity: {
stage: "barStage",
data: "bar bar bar bar"
}
};
var entry = cs.recordEntry("foo", config);
var res = entry.id;
ok(entry.id != null, "Entry.id is: " + res);
ok(cs.displayIndexes["foo"].length == 1,
"We added one entry.");
entry = cs.getEntry(res);
ok(entry.id > -1,
"We got an entry through the global interface");
}
function testRecordManyEntries() {
var configArr = [];
for (var i = 0; i < 1000; i++){
let config = {
logLevel: "network",
message: "HumminaHummina!",
activity: {
stage: "barStage",
data: "bar bar bar bar"
}
};
configArr.push(config);
}
var start = Date.now();
cs.recordEntries("foo", configArr);
var end = Date.now();
var elapsed = end - start;
ok(cs.displayIndexes["foo"].length == 1001,
"1001 entries in foo now");
}
function testIteration() {
var id = "foo";
var it = cs.displayStore(id);
var entry = it.next();
var entry2 = it.next();
let entries = [];
for (var i = 0; i < 100; i++) {
let _entry = it.next();
entries.push(_entry);
}
ok(entries.length == 100, "entries length == 100");
let entries2 = [];
for (var i = 0; i < 100; i++){
let _entry = it.next();
entries2.push(_entry);
}
ok(entries[0].id != entries2[0].id,
"two distinct pages of log entries");
}
let tab, browser, hudId, hud, filterBox, outputNode, cs;
let win = gBrowser.selectedBrowser;
tab = gBrowser.selectedTab;
browser = gBrowser.getBrowserForTab(tab);
function test() {
waitForExplicitFinish();
browser.addEventListener("DOMContentLoaded", function onLoad(event) {
browser.removeEventListener("DOMContentLoaded", onLoad, false);
HUDService.activateHUDForContext(tab);
hudId = HUDService.displaysIndex()[0];
hud = HUDService.getHeadsUpDisplay(hudId);
cs = HUDService.storage;
// enter some filter text into the filter textbox
filterBox = hud.querySelectorAll(".hud-filter-box")[0];
outputNode = HUDService.getHeadsUpDisplay(hudId);
executeSoon(function () {
testRegistries();
testGetDisplayByURISpec();
introspectLogNodes();
getAllHUDS();
getHUDById();
testGetDisplayByLoadGroup();
testGetContentWindowFromHUDId();
content.location.href = TEST_FILTER_URI;
testConsoleLoggingAPI("log");
testConsoleLoggingAPI("info");
testConsoleLoggingAPI("warn");
testConsoleLoggingAPI("error");
testConsoleLoggingAPI("exception");
testNet();
// testDOMMutation();
// ConsoleStorageTests
testCreateDisplay();
testRecordEntry();
testRecordManyEntries();
testIteration();
testUnregister();
finish();
});
}, false);
}

View File

@ -0,0 +1,22 @@
<!DOCTYPE HTML>
<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
<title>Console test</title>
<script type="text/javascript">
dump("i am dumping this");
function test() {
var str = "Dolske Digs Bacon, Now and Forevermore."
for (var i=0; i < 5; i++) {
console.log(str);
}
}
console.info("INLINE SCRIPT:");
test();
console.warn("I'm warning you, he will eat up all yr bacon.");
console.error("Error Message");
</script>
</head>
<body>
<h1>Heads Up Display Demo</h1>
<button onclick="test();">Log stuff about Dolske</button>
</body>
</html>

View File

@ -0,0 +1 @@
{ id: "test JSON data", myArray: [ "foo", "bar", "baz", "biff" ] }

View File

@ -0,0 +1,10 @@
<!DOCTYPE HTML>
<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
<title>Console test</title>
<script type="text/javascript">
</script>
</head>
<body>
<h1>Heads Up Display Filter Test Page</h1>
</body>
</html>

View File

@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<html dir="ltr" xml:lang="en-US" lang="en-US">
<head>
<title>Console mutation test</title>
<script>
window.onload = function (){
var node = document.createElement("div");
document.body.appendChild(node);
};
</script>
</head>
<body>
<h1>Heads Up Display DOM Mutation Test Page</h1>
</body>
</html>

View File

@ -0,0 +1,9 @@
<!DOCTYPE HTML>
<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
<title>Console network test</title>
<script src="testscript.js"></script>
</head>
<body>
<h1>Heads Up Display Network Test Page</h1>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
<title>Console HTTP test page</title>
<script type="text/javascript">
function test() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('get', 'test-data.json', false);
xmlhttp.send(null);
}
</script>
</head>
<body onload="test();">
<h1>Heads Up Display HTTP & AJAX Test Page</h1>
<h2>This page fires an ajax request so we can see the http logging of the console</h2>
</body>
</html>

View File

@ -0,0 +1 @@
console.log("running network console logging tests");

View File

@ -3,3 +3,4 @@ toolkit.jar:
*+ content/global/console.xul (content/console.xul)
+ content/global/console.css (content/console.css)
+ content/global/consoleBindings.xml (content/consoleBindings.xml)
*+ content/global/headsUpDisplay.css (content/headsUpDisplay.css)

View File

@ -0,0 +1,64 @@
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is DevTools Code
-
- The Initial Developer of the Original Code is
- Mozilla Foundation
- Portions created by the Initial Developer are Copyright (C) 2010
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- David Dahl <ddahl@mozilla.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<!ENTITY hud.title "Heads Up Display">
<!ENTITY errFile.label "Source File:">
<!ENTITY errLine.label "Line:">
<!ENTITY errColumn.label "Column:">
<!ENTITY all.label "All">
<!ENTITY all.accesskey "A">
<!ENTITY errors.label "Errors">
<!ENTITY errors.accesskey "E">
<!ENTITY warnings.label "Warnings">
<!ENTITY warnings.accesskey "W">
<!ENTITY messages.label "Messages">
<!ENTITY messages.accesskey "M">
<!ENTITY clear.label "Clear">
<!ENTITY clear.accesskey "C">
<!ENTITY codeEval.label "Code:">
<!ENTITY codeEval.accesskey "o">
<!ENTITY evaluate.label "Evaluate">
<!ENTITY evaluate.accesskey "v">
<!ENTITY copyCmd.label "Copy">
<!ENTITY copyCmd.accesskey "C">
<!ENTITY copyCmd.commandkey "C">
<!ENTITY closeCmd.commandkey "w">
<!ENTITY focus1.commandkey "l">
<!ENTITY focus2.commandkey "d">

View File

@ -0,0 +1,37 @@
typeError=Error:
typeWarning=Warning:
typeNetwork=Network:
typeException=Exception:
typeCssParser=CSS Parser:
typeStrict=Strict Warning:
msgCategory=Category:
errFile=Source File: %S
errLine=Line: %S
errLineCol=Line: %S, Column: %S
errCode=Source Code:
hudTitle=Heads Up Display
jsWorkspaceTitle=JS Workspace
btnHide=Hide
btnPrefs=Preferences
btnMutation=DOM Mutation
tipMutation=Toggle DOM Mutation event logging
btnNetwork=Network
tipNetwork=Toggle Network event logging
btnCSSParser=CSS Warnings
tipCSSParser=Toggle CSS Warning logging
btnException=Exceptions
tipException=Toggle Exception logging
btnError=Error
tipError=Toggle console.error logging
btnInfo=Info
tipInfo=Toggle console.info logging
btnWarn=Warnings
tipWarn=Toggle console.warn logging
btnLog=Log
tipLog=Toggle console.log logging
btnGlobal=Global Messages
tipGlobal=Toggle Global Message logging
localConsole=Local Console
btnClear=Clear Console
tipClear=Clear the console output
stringFilterClear=Clear Filter

View File

@ -35,6 +35,8 @@
+ locale/@AB_CD@/global/finddialog.dtd (%chrome/global/finddialog.dtd)
+ locale/@AB_CD@/global/finddialog.properties (%chrome/global/finddialog.properties)
locale/@AB_CD@/global/globalKeys.dtd (%chrome/global/globalKeys.dtd)
* locale/@AB_CD@/global/headsUpDisplay.dtd (%chrome/global/headsUpDisplay.dtd)
+ locale/@AB_CD@/global/headsUpDisplay.properties (%chrome/global/headsUpDisplay.properties)
+ locale/@AB_CD@/global/intl.css (%chrome/global/intl.css)
+ locale/@AB_CD@/global/intl.properties (%chrome/global/intl.properties)
+ locale/@AB_CD@/global/keys.properties (%chrome/global/keys.properties)