Bug 1437849 - Enable browser_console_hide_jsterm_when_devtools_chrome_enabled_false.js in new frontend r=Honza

This whole test neede rewriting. Beginning with the new console frontend we no longer block the object inspector in the browser console when `devtools.chrome.enabled === false`.

MozReview-Commit-ID: 9H5FvIbkYzk

--HG--
rename : devtools/client/webconsole/new-console-output/test/mochitest/browser_console_hide_jsterm_when_devtools_chrome_enabled_false.js => devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_hide_when_devtools_chrome_enabled_false.js
extra : rebase_source : a649b20be57d394ff24c5f2bafaf1d2b8687ff40
This commit is contained in:
Michael Ratcliffe 2018-02-15 13:12:17 +00:00
Родитель 76611ed894
Коммит 62aa51edea
3 изменённых файлов: 113 добавлений и 116 удалений

Просмотреть файл

@ -179,8 +179,6 @@ skip-if = true # Bug 1437845
skip-if = true # Bug 1437847
[browser_console_filters.js]
skip-if = true # Bug 1437848
[browser_console_hide_jsterm_when_devtools_chrome_enabled_false.js]
skip-if = true # Bug 1437849
[browser_console_nsiconsolemessage.js]
skip-if = true # Bug 1437850
[browser_console_open_or_focus.js]
@ -224,6 +222,7 @@ skip-if = os != 'mac' # The tested ctrl+key shortcuts are OSX only
[browser_jsterm_helper_help.js]
[browser_jsterm_helper_keys_values.js]
[browser_jsterm_helper_pprint.js]
[browser_jsterm_hide_when_devtools_chrome_enabled_false.js]
[browser_jsterm_history.js]
[browser_jsterm_history_persist.js]
[browser_jsterm_history_nav.js]

Просмотреть файл

@ -1,114 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/*
* 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.
* -webconsole jsterm should be enabled
* -webconsole object inspector properties should be set.
*
* when devtools.chrome.enabled == false then
* -browser console jsterm should be disabled
* -browser console object inspector properties should not be set.
* -webconsole jsterm should be enabled
* -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");
is(variablesView.delete, null, "vview.delete is null");
}
function* getVariablesView(hud) {
function openVariablesView(event, vview) {
deferred.resolve(vview._variablesView);
}
let deferred = defer();
// Filter out other messages to ensure ours stays visible.
hud.ui.filterBox.value = "browser_console_hide_jsterm_test";
hud.jsterm.clearOutput();
hud.jsterm.execute("new Object({ browser_console_hide_jsterm_test: true })");
let [message] = yield waitForMessages({
webconsole: hud,
messages: [{
text: "Object { browser_console_hide_jsterm_test: true }",
category: CATEGORY_OUTPUT,
}],
});
hud.jsterm.once("variablesview-fetched", openVariablesView);
let anchor = [...message.matched][0].querySelector("a");
executeSoon(() =>
EventUtils.synthesizeMouse(anchor, 2, 2, {}, hud.iframeWindow)
);
return deferred.promise;
}
function testJSTermIsVisible(hud) {
let inputContainer = hud.ui.window.document
.querySelector(".jsterm-input-container");
isnot(inputContainer.style.display, "none", "input is visible");
}
function testObjectInspectorPropertiesAreSet(variablesView) {
isnot(variablesView.eval, null, "vview.eval is set");
isnot(variablesView.switch, null, "vview.switch is set");
isnot(variablesView.delete, null, "vview.delete is set");
}
function testJSTermIsNotVisible(hud) {
let inputContainer = hud.ui.window.document
.querySelector(".jsterm-input-container");
is(inputContainer.style.display, "none", "input is not visible");
}
function* testRunner() {
let browserConsole, webConsole, variablesView;
Services.prefs.setBoolPref("devtools.chrome.enabled", true);
browserConsole = yield HUDService.toggleBrowserConsole();
variablesView = yield getVariablesView(browserConsole);
testJSTermIsVisible(browserConsole);
testObjectInspectorPropertiesAreSet(variablesView);
let {tab: browserTab} = yield loadTab("data:text/html;charset=utf8,hello world");
webConsole = yield openConsole(browserTab);
variablesView = yield getVariablesView(webConsole);
testJSTermIsVisible(webConsole);
testObjectInspectorPropertiesAreSet(variablesView);
yield closeConsole(browserTab);
yield HUDService.toggleBrowserConsole();
Services.prefs.setBoolPref("devtools.chrome.enabled", false);
browserConsole = yield HUDService.toggleBrowserConsole();
variablesView = yield getVariablesView(browserConsole);
testJSTermIsNotVisible(browserConsole);
testObjectInspectorPropertiesAreNotSet(variablesView);
webConsole = yield openConsole(browserTab);
variablesView = yield getVariablesView(webConsole);
testJSTermIsVisible(webConsole);
testObjectInspectorPropertiesAreSet(variablesView);
yield closeConsole(browserTab);
}
function test() {
Task.spawn(testRunner).then(finishTest);
}

Просмотреть файл

@ -0,0 +1,112 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from head.js */
/*
* 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.
* - webconsole jsterm should be enabled
* - webconsole object inspector properties should be set.
*
* when devtools.chrome.enabled === false then
* - browser console jsterm should be disabled
* - browser console object inspector properties should be set (we used to not
* set them but there is no reason not to do so as the input is disabled).
* - webconsole jsterm should be enabled
* - webconsole object inspector properties should be set.
*/
"use strict";
add_task(async function () {
let browserConsole, webConsole, objInspector;
// We don't use `pushPref()` because we need to revert the same pref later
// in the test.
Services.prefs.setBoolPref("devtools.chrome.enabled", true);
browserConsole = await HUDService.toggleBrowserConsole();
objInspector = await getObjectInspector(browserConsole);
testJSTermIsVisible(browserConsole);
await testObjectInspectorPropertiesAreSet(objInspector);
let browserTab = await addTab("data:text/html;charset=utf8,hello world");
webConsole = await openConsole(browserTab);
objInspector = await getObjectInspector(webConsole);
testJSTermIsVisible(webConsole);
await testObjectInspectorPropertiesAreSet(objInspector);
await closeConsole(browserTab);
await HUDService.toggleBrowserConsole();
Services.prefs.setBoolPref("devtools.chrome.enabled", false);
browserConsole = await HUDService.toggleBrowserConsole();
objInspector = await getObjectInspector(browserConsole);
testJSTermIsNotVisible(browserConsole);
webConsole = await openConsole(browserTab);
objInspector = await getObjectInspector(webConsole);
testJSTermIsVisible(webConsole);
await testObjectInspectorPropertiesAreSet(objInspector);
await closeConsole(browserTab);
});
/**
* Returns either the Variables View or Object Inspector depending on which is
* currently in use.
*/
async function getObjectInspector(hud) {
let { ui, jsterm } = hud;
// Filter out other messages to ensure ours stays visible.
ui.filterBox.value = "browser_console_hide_jsterm_test";
jsterm.clearOutput();
jsterm.execute("new Object({ browser_console_hide_jsterm_test: true })");
let message = await waitFor(
() => findMessage(hud, "Object { browser_console_hide_jsterm_test: true }")
);
let objInspector = message.querySelector(".tree");
return objInspector;
}
function testJSTermIsVisible(hud) {
let inputContainer = hud.ui.window.document
.querySelector(".jsterm-input-container");
isnot(inputContainer.style.display, "none", "input is visible");
}
async function testObjectInspectorPropertiesAreSet(objInspector) {
let onMutation = waitForNodeMutation(objInspector, {
childList: true
});
let arrow = objInspector.querySelector(".arrow");
arrow.click();
await onMutation;
ok(arrow.classList.contains("expanded"),
"The arrow of the root node of the tree is expanded after clicking on it");
let nameNode = objInspector.querySelector(".node:not(.lessen) .object-label");
let container = nameNode.parentNode;
let name = nameNode.textContent;
let value = container.querySelector(".objectBox").textContent;
is(name, "browser_console_hide_jsterm_test", "name is set correctly");
is(value, "true", "value is set correctly");
}
function testJSTermIsNotVisible(hud) {
let inputContainer = hud.ui.window.document
.querySelector(".jsterm-input-container");
is(inputContainer.style.display, "none", "input is not visible");
}