Back out c451a7f1de44 (bug 1050691) for OS X timeouts in browser_webconsole_closure_inspection.js

This commit is contained in:
Phil Ringnalda 2015-06-16 19:37:12 -07:00
parent fc9a2d751c
commit 3cb7402d5e
18 changed files with 31 additions and 263 deletions

View File

@ -1543,7 +1543,7 @@ Scope.prototype = {
*
* @param string a
* @param string b
* @return number
* @return number
* -1 if a is less than b, 0 if no change in order, +1 if a is greater than 0
*/
_naturalSort: function(a,b) {

View File

@ -342,10 +342,6 @@ ConsoleOutput.prototype = {
this.owner.owner.openLink.apply(this.owner.owner, arguments);
},
openLocationInDebugger: function ({url, line}) {
return this.owner.owner.viewSourceInDebugger(url, line);
},
/**
* Open the variables view to inspect an object actor.
* @see JSTerm.openVariablesView() in webconsole.js
@ -2500,8 +2496,6 @@ Widgets.JSObject.prototype = Heritage.extend(Widgets.BaseWidget.prototype,
options.onClick = options.href ? this._onClickAnchor : this._onClick;
}
options.onContextMenu = options.onContextMenu || this._onContextMenu;
let anchor = this.el("a", {
class: options.className,
draggable: false,
@ -2510,8 +2504,6 @@ Widgets.JSObject.prototype = Heritage.extend(Widgets.BaseWidget.prototype,
this.message._addLinkCallback(anchor, options.onClick);
anchor.addEventListener("contextmenu", options.onContextMenu.bind(this));
if (options.appendTo) {
options.appendTo.appendChild(anchor);
} else if (!("appendTo" in options) && this.element) {
@ -2521,38 +2513,16 @@ Widgets.JSObject.prototype = Heritage.extend(Widgets.BaseWidget.prototype,
return anchor;
},
openObjectInVariablesView: function()
{
this.output.openVariablesView({
label: VariablesView.getString(this.objectActor, { concise: true }),
objectActor: this.objectActor,
autofocus: true,
});
},
/**
* The click event handler for objects shown inline.
* @private
*/
_onClick: function()
{
this.openObjectInVariablesView();
},
_onContextMenu: function(ev) {
// TODO offer a nice API for the context menu.
// Probably worth to take a look at Firebug's way
// https://github.com/firebug/firebug/blob/master/extension/content/firebug/chrome/menu.js
let doc = ev.target.ownerDocument;
let cmPopup = doc.getElementById("output-contextmenu");
let openInVarViewCmd = doc.getElementById("menu_openInVarView");
let openVarView = this.openObjectInVariablesView.bind(this);
openInVarViewCmd.addEventListener("command", openVarView);
openInVarViewCmd.removeAttribute("disabled");
cmPopup.addEventListener("popuphiding", function onPopupHiding() {
cmPopup.removeEventListener("popuphiding", onPopupHiding);
openInVarViewCmd.removeEventListener("command", openVarView);
openInVarViewCmd.setAttribute("disabled", "true");
this.output.openVariablesView({
label: VariablesView.getString(this.objectActor, { concise: true }),
objectActor: this.objectActor,
autofocus: true,
});
},
@ -2720,16 +2690,6 @@ Widgets.ObjectRenderers.add({
this._text(")");
},
_onClick: function () {
let location = this.objectActor.location;
if (location) {
this.output.openLocationInDebugger(location);
}
else {
this.openObjectInVariablesView();
}
}
}); // Widgets.ObjectRenderers.byClass.Function
/**

View File

@ -124,8 +124,6 @@ support-files =
test-bug-609872-cd-iframe-parent.html
test-bug-609872-cd-iframe-child.html
test-bug-989025-iframe-parent.html
test-bug_1050691_click_function_to_source.html
test-bug_1050691_click_function_to_source.js
test-console-api-stackframe.html
test_bug_1010953_cspro.html^headers^
test_bug_1010953_cspro.html
@ -389,5 +387,3 @@ skip-if = e10s # Bug 1042253 - webconsole e10s tests (Linux debug timeout)
[browser_webconsole_bug_922212_console_dirxml.js]
[browser_webconsole_shows_reqs_in_netmonitor.js]
[browser_netmonitor_shows_reqs_in_webconsole.js]
[browser_webconsole_bug_1050691_click_function_to_source.js]
[browser_webconsole_context_menu_open_in_var_view.js]

View File

@ -1,60 +0,0 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
// Tests that clicking on a function displays its source in the debugger.
"use strict";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug_1050691_click_function_to_source.html";
let test = asyncTest(function*() {
yield loadTab(TEST_URI);
let hud = yield openConsole();
yield testWithoutDebuggerOpen(hud);
// Open the Debugger panel.
let debuggerPanel = yield openDebugger();
// And right after come back to the Console panel.
yield openConsole();
yield testWithDebuggerOpen(hud, debuggerPanel);
});
function* testWithoutDebuggerOpen(hud) {
let clickable = yield printFunction(hud);
let onVariablesViewOpen = hud.jsterm.once("variablesview-fetched");
synthesizeClick(clickable, hud);
return onVariablesViewOpen;
}
function* testWithDebuggerOpen(hud, debuggerPanel) {
let clickable = yield printFunction(hud);
let panelWin = debuggerPanel.panelWin;
let onEditorLocationSet = panelWin.once(panelWin.EVENTS.EDITOR_LOCATION_SET);
synthesizeClick(clickable, hud);
yield onEditorLocationSet;
ok(isDebuggerCaretPos(debuggerPanel, 7),
"Clicking on a function should go to its source in the debugger view");
}
function synthesizeClick(clickable, hud) {
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
}
let printFunction = Task.async(function* (hud) {
hud.jsterm.clearOutput();
content.wrappedJSObject.foo();
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
}],
});
let msg = [...result.matched][0];
let clickable = msg.querySelector("a");
ok(clickable, "clickable item for object should exist");
return clickable;
});

View File

@ -39,7 +39,7 @@ function test()
return deferred.promise;
});
});
})
});
}
@ -65,15 +65,7 @@ function onExecuteGetName(aResults)
ok(clickable, "clickable object found");
gJSTerm.once("variablesview-fetched", onGetNameFetch);
let contextMenu =
gWebConsole.iframeWindow.document.getElementById("output-contextmenu");
waitForContextMenu(contextMenu, clickable, () => {
let openInVarView = contextMenu.querySelector("#menu_openInVarView");
ok(openInVarView.disabled === false,
"the \"Open In Variables View\" context menu item should be clickable");
EventUtils.synthesizeMouseAtCenter(openInVarView, {},
gWebConsole.iframeWindow);
});
EventUtils.synthesizeMouse(clickable, 2, 2, {}, gWebConsole.iframeWindow);
}
function onGetNameFetch(aEvent, aVar)

View File

@ -1,51 +0,0 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
// Tests that the "Open in Variables View" context menu item is enabled
// only for objects.
"use strict";
const TEST_URI = `data:text/html,<script>
console.log("foo");
console.log("foo", window);
</script>`;
let test = asyncTest(function*() {
yield loadTab(TEST_URI);
let hud = yield openConsole();
let [result] = yield waitForMessages({
webconsole: hud,
messages: [{
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
count: 2,
text: /foo/
}],
});
let [msgWithText, msgWithObj] = [...result.matched];
ok(msgWithText && msgWithObj, "Two messages should have appeared");
let contextMenu = hud.iframeWindow.
document.getElementById("output-contextmenu");
let openInVarViewItem = contextMenu.querySelector("#menu_openInVarView");
let obj = msgWithObj.querySelector(".cm-variable");
let text = msgWithText.querySelector(".console-string");
yield waitForContextMenu(contextMenu, obj, () => {
ok(openInVarViewItem.disabled === false, "The \"Open In Variables View\" " +
"context menu item should be available for objects");
}, () => {
ok(openInVarViewItem.disabled === true, "The \"Open In Variables View\" " +
"context menu item should be disabled on popup hiding");
});
yield waitForContextMenu(contextMenu, text, () => {
ok(openInVarViewItem.disabled === true, "The \"Open In Variables View\" " +
"context menu item should be disabled for texts");
});
});

View File

@ -226,8 +226,6 @@ let closeConsole = Task.async(function* (aTab) {
*/
function waitForContextMenu(aPopup, aButton, aOnShown, aOnHidden)
{
let deferred = promise.defer();
function onPopupShown() {
info("onPopupShown");
aPopup.removeEventListener("popupshown", onPopupShown);
@ -247,10 +245,11 @@ function waitForContextMenu(aPopup, aButton, aOnShown, aOnHidden)
deferred.resolve(aPopup);
}
let deferred = promise.defer();
aPopup.addEventListener("popupshown", onPopupShown);
info("wait for the context menu to open");
let eventDetails = {type: "contextmenu", button: 2};
let eventDetails = { type: "contextmenu", button: 2};
EventUtils.synthesizeMouse(aButton, 2, 2, eventDetails,
aButton.ownerDocument.defaultView);
return deferred.promise;
@ -826,7 +825,7 @@ function openDebugger(aOptions = {})
let target = TargetFactory.forTab(aOptions.tab);
let toolbox = gDevTools.getToolbox(target);
let dbgPanelAlreadyOpen = toolbox && toolbox.getPanel("jsdebugger");
let dbgPanelAlreadyOpen = toolbox.getPanel("jsdebugger");
gDevTools.showToolbox(target, "jsdebugger").then(function onSuccess(aToolbox) {
let panel = aToolbox.getCurrentPanel();
@ -857,24 +856,6 @@ function openDebugger(aOptions = {})
return deferred.promise;
}
/**
* Returns true if the caret in the debugger editor is placed at the specified
* position.
* @param aPanel The debugger panel.
* @param {number} aLine The line number.
* @param {number} [aCol] The column number.
* @returns {boolean}
*/
function isDebuggerCaretPos(aPanel, aLine, aCol = 1) {
let editor = aPanel.panelWin.DebuggerView.editor;
let cursor = editor.getCursor();
// Source editor starts counting line and column numbers from 0.
info("Current editor caret position: " + (cursor.line + 1) + ", " +
(cursor.ch + 1));
return cursor.line == (aLine - 1) && cursor.ch == (aCol - 1);
}
/**
* Wait for messages in the Web Console output.
*

View File

@ -1,11 +0,0 @@
<!DOCTYPE HTML>
<html dir="ltr" xml:lang="en-US" lang="en-US">
<head>
<meta charset="utf-8">
<title>Click on function should point to source</title>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<script type="text/javascript" src="test-bug_1050691_click_function_to_source.js"></script>
</head>
<body></body>
</html>

View File

@ -1,10 +0,0 @@
/**
* this
* is
* a
* function
*/
function foo() {
console.log(foo);
}

View File

@ -76,8 +76,6 @@ function goUpdateConsoleCommands() {
<menuitem id="menu_copyURL" label="&copyURLCmd.label;"
accesskey="&copyURLCmd.accesskey;" command="consoleCmd_copyURL"
selection="network" selectionType="single"/>
<menuitem id="menu_openInVarView" label="&openInVarViewCmd.label;"
accesskey="&openInVarViewCmd.accesskey;" disabled="true"/>
<menuitem id="cMenu_copy"/>
<menuitem id="cMenu_selectAll"/>
</menupopup>

View File

@ -107,5 +107,3 @@
<!ENTITY closeCmd.key "W">
<!ENTITY findCmd.key "F">
<!ENTITY clearOutputCtrl.key "L">
<!ENTITY openInVarViewCmd.label "Open in Variables View">
<!ENTITY openInVarViewCmd.accesskey "V">

View File

@ -25,7 +25,7 @@ function BrowserAddonActor(aConnection, aAddon) {
this._addon = aAddon;
this._contextPool = new ActorPool(this.conn);
this.conn.addActorPool(this._contextPool);
this.threadActor = null;
this._threadActor = null;
this._global = null;
this._shouldAddNewGlobalAsDebuggee = this._shouldAddNewGlobalAsDebuggee.bind(this);
@ -55,7 +55,7 @@ BrowserAddonActor.prototype = {
},
get attached() {
return this.threadActor;
return this._threadActor;
},
get global() {
@ -65,7 +65,7 @@ BrowserAddonActor.prototype = {
get sources() {
if (!this._sources) {
dbg_assert(this.threadActor, "threadActor should exist when creating sources.");
this._sources = new TabSources(this.threadActor, this._allowSource);
this._sources = new TabSources(this._threadActor, this._allowSource);
}
return this._sources;
},
@ -135,11 +135,11 @@ BrowserAddonActor.prototype = {
}
if (!this.attached) {
this.threadActor = new AddonThreadActor(this.conn, this);
this._contextPool.addActor(this.threadActor);
this._threadActor = new AddonThreadActor(this.conn, this);
this._contextPool.addActor(this._threadActor);
}
return { type: "tabAttached", threadActor: this.threadActor.actorID };
return { type: "tabAttached", threadActor: this._threadActor.actorID };
},
onDetach: function BAA_onDetach() {
@ -147,9 +147,9 @@ BrowserAddonActor.prototype = {
return { error: "wrongState" };
}
this._contextPool.removeActor(this.threadActor);
this._contextPool.removeActor(this._threadActor);
this.threadActor = null;
this._threadActor = null;
this._sources = null;
return { type: "detached" };

View File

@ -18,7 +18,7 @@ function ChildProcessActor(aConnection) {
this.conn = aConnection;
this._contextPool = new ActorPool(this.conn);
this.conn.addActorPool(this._contextPool);
this.threadActor = null;
this._threadActor = null;
// Use a see-everything debugger
this.makeDebugger = makeDebugger.bind(null, {
@ -56,8 +56,8 @@ ChildProcessActor.prototype = {
get sources() {
if (!this._sources) {
dbg_assert(this.threadActor, "threadActor should exist when creating sources.");
this._sources = new TabSources(this.threadActor);
dbg_assert(this._threadActor, "threadActor should exist when creating sources.");
this._sources = new TabSources(this._threadActor);
}
return this._sources;
},
@ -68,9 +68,9 @@ ChildProcessActor.prototype = {
this._contextPool.addActor(this._consoleActor);
}
if (!this.threadActor) {
this.threadActor = new ChromeDebuggerActor(this.conn, this);
this._contextPool.addActor(this.threadActor);
if (!this._threadActor) {
this._threadActor = new ChromeDebuggerActor(this.conn, this);
this._contextPool.addActor(this._threadActor);
}
return {
@ -78,7 +78,7 @@ ChildProcessActor.prototype = {
name: "Content process",
consoleActor: this._consoleActor.actorID,
chromeDebugger: this.threadActor.actorID,
chromeDebugger: this._threadActor.actorID,
traits: {
highlightable: false,

View File

@ -42,10 +42,6 @@ const OBJECT_PREVIEW_MAX_ITEMS = 10;
* Increment the actor's grip depth
* - decrementGripDepth
* Decrement the actor's grip depth
* - getGlobalDebugObject
* Getter for the Debuggee Global Object as given by
* the ThreadActor. This global corresponds to the frame selected
* by the frame selector.
*/
function ObjectActor(obj, {
createValueGrip,
@ -53,8 +49,7 @@ function ObjectActor(obj, {
createEnvironmentActor,
getGripDepth,
incrementGripDepth,
decrementGripDepth,
getGlobalDebugObject
decrementGripDepth
}) {
dbg_assert(!obj.optimizedOut,
"Should not create object actors for optimized out values!");
@ -65,8 +60,7 @@ function ObjectActor(obj, {
createEnvironmentActor,
getGripDepth,
incrementGripDepth,
decrementGripDepth,
getGlobalDebugObject
decrementGripDepth
};
this.iterators = new Set();
}
@ -810,17 +804,6 @@ DebuggerServer.ObjectActorPreviewers = {
grip.userDisplayName = hooks.createValueGrip(userDisplayName.value);
}
let dbgGlobal = hooks.getGlobalDebugObject();
if (dbgGlobal) {
let script = dbgGlobal.makeDebuggeeValue(obj.unsafeDereference()).script;
if (script) {
grip.location = {
url: script.url,
line: script.startLine
};
}
}
return true;
}],

View File

@ -145,9 +145,7 @@ let PromisesActor = protocol.ActorClass({
sources: () => DevToolsUtils.reportException("PromisesActor",
Error("sources not yet implemented")),
createEnvironmentActor: () => DevToolsUtils.reportException(
"PromisesActor", Error("createEnvironmentActor not yet implemented")),
getGlobalDebugObject: () => DevToolsUtils.reportException(
"PromisesActor", Error("getGlobalDebugObject not yet implemented")),
"PromisesActor", Error("createEnvironmentActor not yet implemented"))
});
this._navigationLifetimePool.addActor(actor);

View File

@ -1675,8 +1675,7 @@ ThreadActor.prototype = {
this.createEnvironmentActor(env, pool),
promote: () => this.threadObjectGrip(actor),
isThreadLifetimePool: () =>
actor.registeredPool !== this.threadLifetimePool,
getGlobalDebugObject: () => this.globalDebugObject
actor.registeredPool !== this.threadLifetimePool
});
aPool.addActor(actor);
aPool.objectActors.set(aValue, actor);

View File

@ -305,10 +305,6 @@ WebConsoleActor.prototype =
actorPrefix: "console",
get globalDebugObject() {
return this.parentActor.threadActor.globalDebugObject;
},
grip: function WCA_grip()
{
return { actor: this.actorID };
@ -454,8 +450,7 @@ WebConsoleActor.prototype =
createValueGrip: v => this.createValueGrip(v),
sources: () => DevToolsUtils.reportException("WebConsoleActor",
Error("sources not yet implemented")),
createEnvironmentActor: (env) => this.createEnvironmentActor(env),
getGlobalDebugObject: () => this.globalDebugObject
createEnvironmentActor: (env) => this.createEnvironmentActor(env)
});
aPool.addActor(actor);
return actor.grip();

View File

@ -95,7 +95,7 @@ TestTabActor.prototype = {
actorPrefix: "TestTabActor",
get window() {
return this._global;
return { wrappedJSObject: this._global };
},
get url() {