зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1177134 - ESLint cleanup for tests. r=pbro
This commit is contained in:
Родитель
e66c933f70
Коммит
0d0ec20be3
|
@ -10,13 +10,18 @@
|
|||
* the according message is displayed in the web console.
|
||||
*/
|
||||
|
||||
const EXPECTED_RESULT = "Not supporting directive 'reflected-xss'. Directive and values will be ignored.";
|
||||
const TEST_FILE = "http://example.com/browser/browser/devtools/webconsole/test/" +
|
||||
"test_bug1045902_console_csp_ignore_reflected_xss_message.html";
|
||||
"use strict";
|
||||
|
||||
const EXPECTED_RESULT = "Not supporting directive 'reflected-xss'. Directive " +
|
||||
"and values will be ignored.";
|
||||
const TEST_FILE = "http://example.com/browser/browser/devtools/webconsole/" +
|
||||
"test/test_bug1045902_console_csp_ignore_reflected_xss_" +
|
||||
"message.html";
|
||||
|
||||
let hud = undefined;
|
||||
|
||||
let TEST_URI = "data:text/html;charset=utf8,Web Console CSP ignoring reflected XSS (bug 1045902)";
|
||||
let TEST_URI = "data:text/html;charset=utf8,Web Console CSP ignoring " +
|
||||
"reflected XSS (bug 1045902)";
|
||||
|
||||
let test = asyncTest(function* () {
|
||||
let { browser } = yield loadTab(TEST_URI);
|
||||
|
@ -29,11 +34,10 @@ let test = asyncTest(function* () {
|
|||
hud = null;
|
||||
});
|
||||
|
||||
|
||||
function loadDocument(browser) {
|
||||
let deferred = promise.defer();
|
||||
|
||||
hud.jsterm.clearOutput()
|
||||
hud.jsterm.clearOutput();
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
deferred.resolve();
|
||||
|
@ -44,15 +48,15 @@ function loadDocument(browser) {
|
|||
}
|
||||
|
||||
function testViolationMessage() {
|
||||
let deferred = promise.defer();
|
||||
let aOutputNode = hud.outputNode;
|
||||
|
||||
return waitForSuccess({
|
||||
name: "Confirming that CSP logs messages to the console when 'reflected-xss' directive is used!",
|
||||
name: "Confirming that CSP logs messages to the console when " +
|
||||
"'reflected-xss' directive is used!",
|
||||
validator: function() {
|
||||
console.log(hud.outputNode.textContent);
|
||||
console.log(aOutputNode.textContent);
|
||||
let success = false;
|
||||
success = hud.outputNode.textContent.indexOf(EXPECTED_RESULT) > -1;
|
||||
success = aOutputNode.textContent.indexOf(EXPECTED_RESULT) > -1;
|
||||
return success;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
"use strict";
|
||||
|
||||
let test = asyncTest(function* () {
|
||||
const TEST_URI1 = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
|
||||
const TEST_URI2 = "http://example.org/browser/browser/devtools/webconsole/test/test-console.html";
|
||||
const TEST_URI1 = "http://example.com/browser/browser/devtools/webconsole/" +
|
||||
"test/test-console.html";
|
||||
const TEST_URI2 = "http://example.org/browser/browser/devtools/webconsole/" +
|
||||
"test/test-console.html";
|
||||
|
||||
yield loadTab(TEST_URI1);
|
||||
let hud = yield openConsole();
|
||||
|
|
|
@ -55,7 +55,8 @@ let test = asyncTest(function* () {
|
|||
});
|
||||
|
||||
hud.jsterm.clearOutput();
|
||||
content.location.reload(); // Reloading will produce network logging
|
||||
// Reloading will produce network logging
|
||||
content.location.reload();
|
||||
|
||||
// Test that the "Copy Link Location" command is enabled and works
|
||||
// as expected for any network-related message.
|
||||
|
@ -80,10 +81,15 @@ let test = asyncTest(function* () {
|
|||
|
||||
let deferred = promise.defer();
|
||||
|
||||
waitForClipboard((aData) => { return aData.trim() == message.url; },
|
||||
() => { goDoCommand(COMMAND_NAME); },
|
||||
() => { deferred.resolve(null); },
|
||||
() => { deferred.reject(null); });
|
||||
waitForClipboard((aData) => {
|
||||
return aData.trim() == message.url;
|
||||
}, () => {
|
||||
goDoCommand(COMMAND_NAME);
|
||||
}, () => {
|
||||
deferred.resolve(null);
|
||||
}, () => {
|
||||
deferred.reject(null);
|
||||
});
|
||||
|
||||
yield deferred.promise;
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-repeated-messages.html";
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/" +
|
||||
"test/test-repeated-messages.html";
|
||||
|
||||
let test = asyncTest(function* () {
|
||||
yield loadTab(TEST_URI);
|
||||
|
@ -46,8 +47,7 @@ let test = asyncTest(function* () {
|
|||
yield clickObject(clickable, i);
|
||||
}
|
||||
|
||||
function* clickObject(obj, i)
|
||||
{
|
||||
function* clickObject(obj, i) {
|
||||
executeSoon(() => {
|
||||
EventUtils.synthesizeMouse(obj, 2, 2, {}, hud.iframeWindow);
|
||||
});
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-eval-in-stackframe.html";
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/" +
|
||||
"test/test-eval-in-stackframe.html";
|
||||
|
||||
function test()
|
||||
{
|
||||
function test() {
|
||||
let hud;
|
||||
|
||||
Task.spawn(runner).then(finishTest);
|
||||
|
|
|
@ -8,12 +8,14 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug-869003-top-window.html";
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/" +
|
||||
"test/test-bug-869003-top-window.html";
|
||||
|
||||
let test = asyncTest(function* () {
|
||||
// This test is slightly more involved: it opens the web console, then the
|
||||
// variables view for a given object, it updates a property in the view and
|
||||
// checks the result. We can get a timeout with debug builds on slower machines.
|
||||
// checks the result. We can get a timeout with debug builds on slower
|
||||
// machines.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
yield loadTab("data:text/html;charset=utf8,<p>hello");
|
||||
|
@ -43,7 +45,7 @@ let test = asyncTest(function* () {
|
|||
ok(body.textContent.includes('{ hello: "world!",'), "message text check");
|
||||
|
||||
executeSoon(() => {
|
||||
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow)
|
||||
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
|
||||
});
|
||||
|
||||
let aVar = yield hud.jsterm.once("variablesview-fetched");
|
||||
|
|
|
@ -54,7 +54,6 @@ let test = asyncTest(function* () {
|
|||
EventUtils.synthesizeKey("w", { accelKey: true });
|
||||
});
|
||||
|
||||
|
||||
yield promise.all([tabClosed.promise, toolboxDestroyed.promise,
|
||||
tabSelected.promise]);
|
||||
info("promise.all resolved. start testing the Browser Console");
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// Test to see if the cached messages are displayed when the console UI is opened.
|
||||
// Test to see if the cached messages are displayed when the console UI is
|
||||
// opened.
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-webconsole-error-observer.html";
|
||||
"use strict";
|
||||
|
||||
function test()
|
||||
{
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/" +
|
||||
"test/test-webconsole-error-observer.html";
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
expectUncaughtException();
|
||||
|
@ -16,8 +19,7 @@ function test()
|
|||
loadTab(TEST_URI).then(testOpenUI);
|
||||
}
|
||||
|
||||
function testOpenUI(aTestReopen)
|
||||
{
|
||||
function testOpenUI(aTestReopen) {
|
||||
openConsole().then((hud) => {
|
||||
waitForMessages({
|
||||
webconsole: hud,
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
|
||||
// Test the basic features of the Browser Console, bug 587757.
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html?" + Date.now();
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/" +
|
||||
"test/test-console.html?" + Date.now();
|
||||
|
||||
const TEST_XHR_ERROR_URI = `http://example.com/404.html?${Date.now()}`;
|
||||
|
||||
|
@ -27,8 +30,7 @@ let test = asyncTest(function*() {
|
|||
yield consoleOpened(hud);
|
||||
});
|
||||
|
||||
function consoleOpened(hud)
|
||||
{
|
||||
function consoleOpened(hud) {
|
||||
hud.jsterm.clearOutput(true);
|
||||
|
||||
expectUncaughtException();
|
||||
|
@ -53,7 +55,9 @@ function consoleOpened(hud)
|
|||
|
||||
// Check for xhr error.
|
||||
let xhrErr = new XMLHttpRequest();
|
||||
xhrErr.onload = () => console.log("xhr error loaded, status is: " + xhrErr.status);
|
||||
xhrErr.onload = () => {
|
||||
console.log("xhr error loaded, status is: " + xhrErr.status);
|
||||
};
|
||||
xhrErr.open("get", TEST_XHR_ERROR_URI, true);
|
||||
xhrErr.send();
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
|
||||
const TEST_URI = "data:text/html;charset=utf8,<p>hello world from bug 866950";
|
||||
|
||||
function test()
|
||||
{
|
||||
function test() {
|
||||
requestLongerTimeout(2);
|
||||
|
||||
let webconsole, browserconsole;
|
||||
|
@ -30,7 +29,8 @@ function test()
|
|||
// Cause an exception in a script loaded with the addon-sdk loader.
|
||||
let toolbox = gDevTools.getToolbox(webconsole.target);
|
||||
let oldPanels = toolbox._toolPanels;
|
||||
toolbox._toolPanels = {}; // non-iterable
|
||||
// non-iterable
|
||||
toolbox._toolPanels = {};
|
||||
|
||||
function fixToolbox() {
|
||||
toolbox._toolPanels = oldPanels;
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
|
||||
let test = asyncTest(function*() {
|
||||
const PREF = "devtools.webconsole.persistlog";
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/" +
|
||||
"test/test-console.html";
|
||||
|
||||
Services.prefs.setBoolPref(PREF, false);
|
||||
registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/" +
|
||||
"test/test-console.html";
|
||||
|
||||
let test = asyncTest(function*() {
|
||||
yield loadTab(TEST_URI);
|
||||
|
@ -32,7 +33,7 @@ let test = asyncTest(function*() {
|
|||
let lostFocus = () => {
|
||||
inputNode.removeEventListener("blur", lostFocus);
|
||||
info("input node lost focus");
|
||||
}
|
||||
};
|
||||
|
||||
inputNode.addEventListener("blur", lostFocus);
|
||||
|
||||
|
@ -42,7 +43,7 @@ let test = asyncTest(function*() {
|
|||
|
||||
EventUtils.sendMouseEvent({type: "click"}, hud.outputNode);
|
||||
|
||||
ok(inputNode.getAttribute("focused"), "input node is focused, second time")
|
||||
ok(inputNode.getAttribute("focused"), "input node is focused, second time");
|
||||
|
||||
// test click-drags are not focusing the input element.
|
||||
EventUtils.sendMouseEvent({type: "mousedown", clientX: 3, clientY: 4},
|
||||
|
|
|
@ -14,10 +14,11 @@ function onNewMessage(aEvent, aNewMessages) {
|
|||
ok(false, "Message shouldn't have been output: " + msg.node.textContent);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
add_task(function*() {
|
||||
let storage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(Ci.nsIConsoleAPIStorage);
|
||||
let consoleStorage = Cc["@mozilla.org/consoleAPI-storage;1"];
|
||||
let storage = consoleStorage.getService(Ci.nsIConsoleAPIStorage);
|
||||
storage.clearEvents();
|
||||
|
||||
let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
|
||||
|
@ -147,8 +148,9 @@ add_task(function*() {
|
|||
yield HUDService.toggleBrowserConsole();
|
||||
});
|
||||
|
||||
add_task(function* test_prefix() {
|
||||
let storage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(Ci.nsIConsoleAPIStorage);
|
||||
add_task(function* testPrefix() {
|
||||
let consoleStorage = Cc["@mozilla.org/consoleAPI-storage;1"];
|
||||
let storage = consoleStorage.getService(Ci.nsIConsoleAPIStorage);
|
||||
storage.clearEvents();
|
||||
|
||||
let {ConsoleAPI} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
|
||||
|
@ -177,8 +179,9 @@ add_task(function* test_prefix() {
|
|||
yield HUDService.toggleBrowserConsole();
|
||||
});
|
||||
|
||||
add_task(function* test_maxLogLevelPref_missing() {
|
||||
let storage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(Ci.nsIConsoleAPIStorage);
|
||||
add_task(function* testMaxLogLevelPrefMissing() {
|
||||
let consoleStorage = Cc["@mozilla.org/consoleAPI-storage;1"];
|
||||
let storage = consoleStorage.getService(Ci.nsIConsoleAPIStorage);
|
||||
storage.clearEvents();
|
||||
|
||||
let {ConsoleAPI} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
|
||||
|
@ -215,8 +218,9 @@ add_task(function* test_maxLogLevelPref_missing() {
|
|||
yield HUDService.toggleBrowserConsole();
|
||||
});
|
||||
|
||||
add_task(function* test_maxLogLevelPref() {
|
||||
let storage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(Ci.nsIConsoleAPIStorage);
|
||||
add_task(function* testMaxLogLevelPref() {
|
||||
let consoleStorage = Cc["@mozilla.org/consoleAPI-storage;1"];
|
||||
let storage = consoleStorage.getService(Ci.nsIConsoleAPIStorage);
|
||||
storage.clearEvents();
|
||||
|
||||
let {ConsoleAPI} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
|
||||
// Tests that the `copy` console helper works as intended.
|
||||
|
||||
"use strict";
|
||||
|
||||
let gWebConsole, gJSTerm;
|
||||
|
||||
let TEXT = "Lorem ipsum dolor sit amet, consectetur adipisicing " +
|
||||
let TEXT = "Lorem ipsum dolor sit amet, consectetur adipisicing " +
|
||||
"elit, sed do eiusmod tempor incididunt ut labore et dolore magna " +
|
||||
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco " +
|
||||
"laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " +
|
||||
|
@ -24,7 +26,7 @@ add_task(function* init() {
|
|||
" <div>" +
|
||||
" <h1>Testing copy command</h1>" +
|
||||
" <p>This is some example text</p>" +
|
||||
" <p id='select-me'>"+TEXT+"</p>" +
|
||||
" <p id='select-me'>" + TEXT + "</p>" +
|
||||
" </div>" +
|
||||
" <div><p></p></div>" +
|
||||
"</body>");
|
||||
|
@ -33,15 +35,19 @@ add_task(function* init() {
|
|||
gJSTerm = gWebConsole.jsterm;
|
||||
});
|
||||
|
||||
add_task(function* test_copy() {
|
||||
add_task(function* testCopy() {
|
||||
let RANDOM = Math.random();
|
||||
let string = "Text: " + RANDOM;
|
||||
let obj = {a: 1, b: "foo", c: RANDOM};
|
||||
|
||||
let samples = [[RANDOM, RANDOM],
|
||||
[JSON.stringify(string), string],
|
||||
[obj.toSource(), JSON.stringify(obj, null, " ")],
|
||||
["$('#" + ID + "')", content.document.getElementById(ID).outerHTML]
|
||||
let samples = [
|
||||
[RANDOM, RANDOM],
|
||||
[JSON.stringify(string), string],
|
||||
[obj.toSource(), JSON.stringify(obj, null, " ")],
|
||||
[
|
||||
"$('#" + ID + "')",
|
||||
content.document.getElementById(ID).outerHTML
|
||||
]
|
||||
];
|
||||
for (let [source, reference] of samples) {
|
||||
let deferredResult = promise.defer();
|
||||
|
|
|
@ -11,8 +11,8 @@ function test() {
|
|||
let outputNode;
|
||||
let contextMenu;
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
|
||||
const TEST_FILE = TEST_URI.substr(TEST_URI.lastIndexOf("/"));
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/" +
|
||||
"test/test-console.html";
|
||||
|
||||
Task.spawn(runner).then(finishTest);
|
||||
|
||||
|
@ -42,23 +42,27 @@ function test() {
|
|||
let message = [...results.matched][0];
|
||||
message.scrollIntoView();
|
||||
|
||||
yield waitForContextMenu(contextMenu, message, copyFromPopup, testContextMenuCopy);
|
||||
yield waitForContextMenu(contextMenu, message, copyFromPopup,
|
||||
testContextMenuCopy);
|
||||
|
||||
function copyFromPopup() {
|
||||
let copyItem = contextMenu.querySelector("#cMenu_copy");
|
||||
copyItem.doCommand();
|
||||
|
||||
let controller = top.document.commandDispatcher.getControllerForCommand("cmd_copy");
|
||||
let controller = top.document.commandDispatcher
|
||||
.getControllerForCommand("cmd_copy");
|
||||
is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled");
|
||||
}
|
||||
|
||||
function testContextMenuCopy() {
|
||||
waitForClipboard((str) => { return message.textContent.trim() == str.trim(); },
|
||||
() => { goDoCommand("cmd_copy") },
|
||||
() => {}, () => {}
|
||||
waitForClipboard((str) => {
|
||||
return message.textContent.trim() == str.trim();
|
||||
}, () => {
|
||||
goDoCommand("cmd_copy");
|
||||
}, () => {}, () => {}
|
||||
);
|
||||
}
|
||||
|
||||
yield closeConsole(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
const TEST_URI = "data:text/html;charset=utf8,<p>dead objects!";
|
||||
|
||||
function test()
|
||||
{
|
||||
function test() {
|
||||
let hud = null;
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
|
@ -28,7 +27,7 @@ function test()
|
|||
|
||||
function* runner() {
|
||||
Services.prefs.setBoolPref("devtools.chrome.enabled", true);
|
||||
let {tab} = yield loadTab(TEST_URI);
|
||||
yield loadTab(TEST_URI);
|
||||
|
||||
info("open the browser console");
|
||||
|
||||
|
@ -42,7 +41,8 @@ function test()
|
|||
// Add the reference to the content document.
|
||||
yield jsterm.execute("Cu = Components.utils;" +
|
||||
"Cu.import('resource://gre/modules/Services.jsm');" +
|
||||
"chromeWindow = Services.wm.getMostRecentWindow('navigator:browser');" +
|
||||
"chromeWindow = Services.wm.getMostRecentWindow('" +
|
||||
"navigator:browser');" +
|
||||
"foobarzTezt = chromeWindow.content.document;" +
|
||||
"delete chromeWindow");
|
||||
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
// Check that JS errors and CSS warnings open view source when their source link
|
||||
// is clicked in the Browser Console. See bug 877778.
|
||||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "data:text/html;charset=utf8,<p>hello world from bug 877778 " +
|
||||
"<button onclick='foobar.explode()' " +
|
||||
"style='test-color: green-please'>click!</button>";
|
||||
function test()
|
||||
{
|
||||
function test() {
|
||||
let hud;
|
||||
|
||||
loadTab(TEST_URI).then(() => {
|
||||
HUDService.toggleBrowserConsole().then(browserConsoleOpened);
|
||||
});
|
||||
|
||||
function browserConsoleOpened(aHud)
|
||||
{
|
||||
function browserConsoleOpened(aHud) {
|
||||
hud = aHud;
|
||||
ok(hud, "browser console opened");
|
||||
|
||||
|
@ -48,8 +48,7 @@ function test()
|
|||
}).then(onMessageFound);
|
||||
}
|
||||
|
||||
function onMessageFound(results)
|
||||
{
|
||||
function onMessageFound(results) {
|
||||
let viewSource = hud.viewSource;
|
||||
let viewSourceCalled = false;
|
||||
hud.viewSourceInDebugger = () => viewSourceCalled = true;
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Bug 922161 - hide Browser Console JS input field if devtools.chrome.enabled is false
|
||||
* Bug 922161 - Hide Browser Console JS input field if devtools.chrome.enabled
|
||||
* is false.
|
||||
* when devtools.chrome.enabled then
|
||||
* -browser console jsterm should be enabled
|
||||
* -browser console object inspector properties should be set.
|
||||
|
@ -18,6 +19,8 @@
|
|||
* -webconsole object inspector properties should be set.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
function testObjectInspectorPropertiesAreNotSet(variablesView) {
|
||||
is(variablesView.eval, null, "vview.eval is null");
|
||||
is(variablesView.switch, null, "vview.switch is null");
|
||||
|
@ -31,7 +34,7 @@ function* getVariablesView(hud) {
|
|||
|
||||
let deferred = promise.defer();
|
||||
hud.jsterm.clearOutput();
|
||||
hud.jsterm.execute('new Object()');
|
||||
hud.jsterm.execute("new Object()");
|
||||
|
||||
let [message] = yield waitForMessages({
|
||||
webconsole: hud,
|
||||
|
@ -39,7 +42,7 @@ function* getVariablesView(hud) {
|
|||
text: "Object",
|
||||
category: CATEGORY_OUTPUT,
|
||||
}],
|
||||
})
|
||||
});
|
||||
|
||||
hud.jsterm.once("variablesview-fetched", openVariablesView);
|
||||
|
||||
|
@ -53,7 +56,8 @@ function* getVariablesView(hud) {
|
|||
}
|
||||
|
||||
function testJSTermIsVisible(hud) {
|
||||
let inputContainer = hud.ui.window.document.querySelector(".jsterm-input-container");
|
||||
let inputContainer = hud.ui.window.document
|
||||
.querySelector(".jsterm-input-container");
|
||||
isnot(inputContainer.style.display, "none", "input is visible");
|
||||
}
|
||||
|
||||
|
@ -64,7 +68,8 @@ function testObjectInspectorPropertiesAreSet(variablesView) {
|
|||
}
|
||||
|
||||
function testJSTermIsNotVisible(hud) {
|
||||
let inputContainer = hud.ui.window.document.querySelector(".jsterm-input-container");
|
||||
let inputContainer = hud.ui.window.document
|
||||
.querySelector(".jsterm-input-container");
|
||||
is(inputContainer.style.display, "none", "input is not visible");
|
||||
}
|
||||
|
||||
|
@ -81,8 +86,8 @@ function* testRunner() {
|
|||
let {tab: browserTab} = yield loadTab("data:text/html;charset=utf8,hello world");
|
||||
webConsole = yield openConsole(browserTab);
|
||||
variablesView = yield getVariablesView(webConsole);
|
||||
testJSTermIsVisible(webConsole)
|
||||
testObjectInspectorPropertiesAreSet(variablesView)
|
||||
testJSTermIsVisible(webConsole);
|
||||
testObjectInspectorPropertiesAreSet(variablesView);
|
||||
yield closeConsole(browserTab);
|
||||
|
||||
yield HUDService.toggleBrowserConsole();
|
||||
|
@ -95,8 +100,8 @@ function* testRunner() {
|
|||
|
||||
webConsole = yield openConsole(browserTab);
|
||||
variablesView = yield getVariablesView(webConsole);
|
||||
testJSTermIsVisible(webConsole)
|
||||
testObjectInspectorPropertiesAreSet(variablesView)
|
||||
testJSTermIsVisible(webConsole);
|
||||
testObjectInspectorPropertiesAreSet(variablesView);
|
||||
yield closeConsole(browserTab);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,67 +8,79 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = "data:text/html;charset=utf-8,Web Console test for persisting history - bug 943306";
|
||||
const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
|
||||
"persisting history - bug 943306";
|
||||
const INPUT_HISTORY_COUNT = 10;
|
||||
|
||||
let test = asyncTest(function* () {
|
||||
info ("Setting custom input history pref to " + INPUT_HISTORY_COUNT);
|
||||
Services.prefs.setIntPref("devtools.webconsole.inputHistoryCount", INPUT_HISTORY_COUNT);
|
||||
info("Setting custom input history pref to " + INPUT_HISTORY_COUNT);
|
||||
Services.prefs.setIntPref("devtools.webconsole.inputHistoryCount",
|
||||
INPUT_HISTORY_COUNT);
|
||||
|
||||
// First tab: run a bunch of commands and then make sure that you can
|
||||
// navigate through their history.
|
||||
yield loadTab(TEST_URI);
|
||||
let hud1 = yield openConsole();
|
||||
is (JSON.stringify(hud1.jsterm.history), "[]", "No history on first tab initially");
|
||||
is(JSON.stringify(hud1.jsterm.history), "[]",
|
||||
"No history on first tab initially");
|
||||
yield populateInputHistory(hud1);
|
||||
is (JSON.stringify(hud1.jsterm.history), '["0","1","2","3","4","5","6","7","8","9"]',
|
||||
"First tab has populated history");
|
||||
is(JSON.stringify(hud1.jsterm.history),
|
||||
'["0","1","2","3","4","5","6","7","8","9"]',
|
||||
"First tab has populated history");
|
||||
|
||||
// Second tab: Just make sure that you can navigate through the history
|
||||
// generated by the first tab.
|
||||
yield loadTab(TEST_URI);
|
||||
let hud2 = yield openConsole();
|
||||
is (JSON.stringify(hud2.jsterm.history), '["0","1","2","3","4","5","6","7","8","9"]',
|
||||
"Second tab has populated history");
|
||||
is(JSON.stringify(hud2.jsterm.history),
|
||||
'["0","1","2","3","4","5","6","7","8","9"]',
|
||||
"Second tab has populated history");
|
||||
yield testNaviatingHistoryInUI(hud2);
|
||||
is (JSON.stringify(hud2.jsterm.history), '["0","1","2","3","4","5","6","7","8","9",""]',
|
||||
"An empty entry has been added in the second tab due to history perusal");
|
||||
is(JSON.stringify(hud2.jsterm.history),
|
||||
'["0","1","2","3","4","5","6","7","8","9",""]',
|
||||
"An empty entry has been added in the second tab due to history perusal");
|
||||
|
||||
// Third tab: Should have the same history as first tab, but if we run a
|
||||
// command, then the history of the first and second shouldn't be affected
|
||||
yield loadTab(TEST_URI);
|
||||
let hud3 = yield openConsole();
|
||||
is (JSON.stringify(hud3.jsterm.history), '["0","1","2","3","4","5","6","7","8","9"]',
|
||||
"Third tab has populated history");
|
||||
is(JSON.stringify(hud3.jsterm.history),
|
||||
'["0","1","2","3","4","5","6","7","8","9"]',
|
||||
"Third tab has populated history");
|
||||
|
||||
// Set input value separately from execute so UP arrow accurately navigates history.
|
||||
hud3.jsterm.setInputValue('"hello from third tab"');
|
||||
hud3.jsterm.execute();
|
||||
|
||||
is (JSON.stringify(hud1.jsterm.history), '["0","1","2","3","4","5","6","7","8","9"]',
|
||||
"First tab history hasn't changed due to command in third tab");
|
||||
is (JSON.stringify(hud2.jsterm.history), '["0","1","2","3","4","5","6","7","8","9",""]',
|
||||
"Second tab history hasn't changed due to command in third tab");
|
||||
is (JSON.stringify(hud3.jsterm.history), '["1","2","3","4","5","6","7","8","9","\\"hello from third tab\\""]',
|
||||
"Third tab has updated history (and purged the first result) after running a command");
|
||||
is(JSON.stringify(hud1.jsterm.history),
|
||||
'["0","1","2","3","4","5","6","7","8","9"]',
|
||||
"First tab history hasn't changed due to command in third tab");
|
||||
is(JSON.stringify(hud2.jsterm.history),
|
||||
'["0","1","2","3","4","5","6","7","8","9",""]',
|
||||
"Second tab history hasn't changed due to command in third tab");
|
||||
is(JSON.stringify(hud3.jsterm.history),
|
||||
'["1","2","3","4","5","6","7","8","9","\\"hello from third tab\\""]',
|
||||
"Third tab has updated history (and purged the first result) after " +
|
||||
"running a command");
|
||||
|
||||
// Fourth tab: Should have the latest command from the third tab, followed
|
||||
// by the rest of the history from the first tab.
|
||||
yield loadTab(TEST_URI);
|
||||
let hud4 = yield openConsole();
|
||||
is (JSON.stringify(hud4.jsterm.history), '["1","2","3","4","5","6","7","8","9","\\"hello from third tab\\""]',
|
||||
"Fourth tab has most recent history");
|
||||
is(JSON.stringify(hud4.jsterm.history),
|
||||
'["1","2","3","4","5","6","7","8","9","\\"hello from third tab\\""]',
|
||||
"Fourth tab has most recent history");
|
||||
|
||||
yield hud4.jsterm.clearHistory();
|
||||
is (JSON.stringify(hud4.jsterm.history), '[]',
|
||||
"Clearing history for a tab works");
|
||||
is(JSON.stringify(hud4.jsterm.history), '[]',
|
||||
"Clearing history for a tab works");
|
||||
|
||||
yield loadTab(TEST_URI);
|
||||
let hud5 = yield openConsole();
|
||||
is (JSON.stringify(hud5.jsterm.history), '[]',
|
||||
"Clearing history carries over to a new tab");
|
||||
is(JSON.stringify(hud5.jsterm.history), '[]',
|
||||
"Clearing history carries over to a new tab");
|
||||
|
||||
info ("Clearing custom input history pref");
|
||||
info("Clearing custom input history pref");
|
||||
Services.prefs.clearUserPref("devtools.webconsole.inputHistoryCount");
|
||||
});
|
||||
|
||||
|
@ -78,10 +90,10 @@ let test = asyncTest(function* () {
|
|||
*/
|
||||
function* populateInputHistory(hud) {
|
||||
let jsterm = hud.jsterm;
|
||||
let {inputNode} = jsterm;
|
||||
|
||||
for (let i = 0; i < INPUT_HISTORY_COUNT; i++) {
|
||||
// Set input value separately from execute so UP arrow accurately navigates history.
|
||||
// Set input value separately from execute so UP arrow accurately navigates
|
||||
// history.
|
||||
jsterm.setInputValue(i);
|
||||
jsterm.execute();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче