Backed out 2 changesets (bug 1575240) for failures in browser_inspector_menu-06-other.js CLOSED TREE

Backed out changeset 0667a378d933 (bug 1575240)
Backed out changeset 74fce607d8a7 (bug 1575240)
This commit is contained in:
Noemi Erli 2019-08-30 00:35:13 +03:00
Родитель 651b2b3dca
Коммит 257da8f0d3
6 изменённых файлов: 23 добавлений и 131 удалений

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

@ -3389,21 +3389,23 @@ Toolbox.prototype = {
objectActor.preview &&
objectActor.preview.nodeType === domNodeConstants.ELEMENT_NODE
) {
return this.viewElementInInspector(objectActor, inspectFromAnnotation);
}
if (objectActor.class == "Function") {
const { url, line } = objectActor.location;
return this.viewSourceInDebugger(url, line);
}
if (objectActor.type !== "null" && objectActor.type !== "undefined") {
// Open the inspector and select the DOM Element.
await this.loadTool("inspector");
const inspector = this.getPanel("inspector");
const nodeFound = await inspector.inspectNodeActor(
objectActor.actor,
inspectFromAnnotation
);
if (nodeFound) {
await this.selectTool("inspector");
}
} else if (
objectActor.type !== "null" &&
objectActor.type !== "undefined"
) {
// Open then split console and inspect the object in the variables view,
// when the objectActor doesn't represent an undefined or null value.
if (this.currentToolId != "webconsole") {
await this.openSplitConsole();
}
await this.openSplitConsole();
const panel = this.getPanel("webconsole");
panel.hud.ui.inspectObjectActor(objectActor);
}
@ -3793,19 +3795,6 @@ Toolbox.prototype = {
);
},
viewElementInInspector: async function(objectActor, inspectFromAnnotation) {
// Open the inspector and select the DOM Element.
await this.loadTool("inspector");
const inspector = this.getPanel("inspector");
const nodeFound = await inspector.inspectNodeActor(
objectActor.actor,
inspectFromAnnotation
);
if (nodeFound) {
await this.selectTool("inspector");
}
},
/**
* Opens source in debugger. Falls back to plain "view-source:".
* @see devtools/client/shared/source-utils.js

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

@ -130,8 +130,6 @@ support-files =
test-non-javascript-mime-worker.html
test-primitive-stacktrace.html
test-reopen-closed-tab.html
test-simple-function.html
test-simple-function.js
test-sourcemap-error-01.html
test-sourcemap-error-01.js
test-sourcemap-error-02.html

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

@ -5,79 +5,21 @@
"use strict";
const TEST_URI =
"https://example.com/browser/devtools/client/webconsole/test/browser/" +
"test-simple-function.html";
const TEST_URI = "data:text/html;charset=utf8,<p>test inspect() command";
// Test Elements and Functions
add_task(async function() {
const hud = await openNewTabAndConsole(TEST_URI);
const toolbox = gDevTools.getToolbox(hud.target);
await testInspectingElement(hud, toolbox);
await testInspectingFunction(hud, toolbox);
});
// Test primitives
add_task(async function() {
const hud = await openNewTabAndConsole(TEST_URI);
await testInspectingWindow(hud);
await testInspectIngPrimitive(hud);
});
async function testInspectingElement(hud, toolbox) {
info("Test `inspect(el)`");
execute(hud, "inspect(document.querySelector('p'))");
await waitForSelectedElementInInspector(toolbox, "p");
ok(true, "inspected element is now selected in the inspector");
}
async function testInspectingFunction(hud, toolbox) {
info("Test `inspect(test)`");
execute(hud, "inspect(test)");
await waitFor(() => {
const dbg = toolbox.getPanel("jsdebugger");
if (!dbg) {
return false;
}
const selectedLocation = dbg._selectors.getSelectedLocation(
dbg._getState()
);
if (!selectedLocation) {
return false;
}
return (
selectedLocation.sourceId.includes("test-simple-function.js") &&
selectedLocation.line == 3
);
});
ok(true, "inspected function is now selected in the debugger");
}
async function testInspectingWindow(hud) {
info("Test `inspect(window)`");
// Add a global value so we can check it later.
execute(hud, "testProp = 'testValue'");
execute(hud, "inspect(window)");
const objectInspectors = await waitFor(() => {
const message = findInspectResultMessage(hud.ui.outputNode, 1);
if (!message) {
return false;
}
const treeEls = message.querySelectorAll(".tree");
if (treeEls.length == 0) {
return false;
}
return [...treeEls];
});
const inspectWindowNode = await waitFor(() =>
findInspectResultMessage(hud.ui.outputNode, 1)
);
const objectInspectors = [...inspectWindowNode.querySelectorAll(".tree")];
is(
objectInspectors.length,
1,
@ -113,9 +55,8 @@ async function testInspectingWindow(hud) {
'"testValue"',
"The testProp property value is displayed as expected"
);
}
async function testInspectIngPrimitive(hud) {
/* Check that a primitive value can be inspected, too */
info("Test `inspect(1)`");
execute(hud, "inspect(1)");
@ -127,24 +68,8 @@ async function testInspectIngPrimitive(hud) {
1,
"The primitive is displayed as expected"
);
}
});
function findInspectResultMessage(node, index) {
return node.querySelectorAll(".message.result")[index];
}
async function waitForSelectedElementInInspector(toolbox, displayName) {
return waitFor(() => {
const inspector = toolbox.getPanel("inspector");
if (!inspector) {
return false;
}
const selection = inspector.selection;
return (
selection &&
selection.nodeFront &&
selection.nodeFront.displayName == displayName
);
});
}

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

@ -1,9 +0,0 @@
<!DOCTYPE html>
<html dir="ltr" xml:lang="en-US" lang="en-US">
<head>
<script src="test-simple-function.js"></script>
</head>
<body>
<p>Test inspecting an element</p>
</body>
</html>

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

@ -1,5 +0,0 @@
"use strict";
window.test = function() {
console.log("simple function");
};

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

@ -235,13 +235,7 @@ class WebConsoleWrapper {
},
getMappedExpression: this.hud.getMappedExpression.bind(this.hud),
getPanelWindow: () => webConsoleUI.window,
inspectObjectActor: objectActor => {
if (this.toolbox) {
this.toolbox.inspectObjectActor(objectActor);
} else {
webConsoleUI.inspectObjectActor(objectActor);
}
},
inspectObjectActor: webConsoleUI.inspectObjectActor.bind(webConsoleUI),
};
// Set `openContextMenu` this way so, `serviceContainer` variable