mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1353042 - Get rid of all sdk/tabs and sdk/tabs/utils usage; r=zer0
Removed obsolete browser_dbg_event-listeners-03/4.js tests (they are for the old debugger, and the new debugger doesn't even support event listeners yet, so no use keeping this test around). Removed getBrowserForTab SDK dependency from command-state.js. Changed the implementation of addTab/removeTab in perf test's tab-utils helper. MozReview-Commit-ID: 7EXJ5K3kaJm --HG-- extra : rebase_source : 1922ba94fe72d3d10e6a4d8a9769cf475b9f113d
This commit is contained in:
parent
14c64f407b
commit
75124a3a75
@ -78,7 +78,6 @@ support-files =
|
||||
doc_event-listeners-01.html
|
||||
doc_event-listeners-02.html
|
||||
doc_event-listeners-03.html
|
||||
doc_event-listeners-04.html
|
||||
doc_frame-parameters.html
|
||||
doc_function-display-name.html
|
||||
doc_function-jump.html
|
||||
@ -182,8 +181,6 @@ skip-if = e10s || true # bug 1113935
|
||||
skip-if = e10s || os == "mac" || e10s # Bug 895426
|
||||
[browser_dbg_break-on-dom-event-02.js]
|
||||
skip-if = e10s # TODO
|
||||
[browser_dbg_break-on-dom-event-03.js]
|
||||
skip-if = e10s # TODO
|
||||
[browser_dbg_break-unselected.js]
|
||||
[browser_dbg_breakpoints-actual-location.js]
|
||||
[browser_dbg_breakpoints-actual-location2.js]
|
||||
@ -269,8 +266,6 @@ skip-if = e10s && debug
|
||||
skip-if = e10s && debug
|
||||
[browser_dbg_event-listeners-03.js]
|
||||
skip-if = e10s && debug
|
||||
[browser_dbg_event-listeners-04.js]
|
||||
skip-if = debug || e10s # debug bug 1142597, e10s bug 1146603.
|
||||
[browser_dbg_file-reload.js]
|
||||
skip-if = e10s && debug
|
||||
[browser_dbg_function-display-name.js]
|
||||
|
@ -1,97 +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/ */
|
||||
|
||||
/**
|
||||
* Tests that the break-on-dom-events request works for load event listeners.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_event-listeners-04.html";
|
||||
|
||||
var gClient, gThreadClient;
|
||||
|
||||
function test() {
|
||||
if (!DebuggerServer.initialized) {
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.addBrowserActors();
|
||||
}
|
||||
|
||||
let transport = DebuggerServer.connectPipe();
|
||||
gClient = new DebuggerClient(transport);
|
||||
gClient.connect().then(([aType, aTraits]) => {
|
||||
is(aType, "browser",
|
||||
"Root actor should identify itself as a browser.");
|
||||
|
||||
addTab(TAB_URL)
|
||||
.then(() => attachThreadActorForUrl(gClient, TAB_URL))
|
||||
.then(aThreadClient => gThreadClient = aThreadClient)
|
||||
.then(pauseDebuggee)
|
||||
.then(testBreakOnLoad)
|
||||
.then(() => gClient.close())
|
||||
.then(finish)
|
||||
.then(null, aError => {
|
||||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function pauseDebuggee() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
gClient.addOneTimeListener("paused", (aEvent, aPacket) => {
|
||||
is(aPacket.type, "paused",
|
||||
"We should now be paused.");
|
||||
is(aPacket.why.type, "debuggerStatement",
|
||||
"The debugger statement was hit.");
|
||||
|
||||
gThreadClient.resume(deferred.resolve);
|
||||
});
|
||||
|
||||
// Spin the event loop before causing the debuggee to pause, to allow
|
||||
// this function to return first.
|
||||
executeSoon(() => triggerButtonClick());
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
// Test pause on a load event.
|
||||
function testBreakOnLoad() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
// Test calling pauseOnDOMEvents from a running state.
|
||||
gThreadClient.pauseOnDOMEvents(["load"], (aPacket) => {
|
||||
is(aPacket.error, undefined,
|
||||
"The pause-on-load request completed successfully.");
|
||||
let handlers = ["loadHandler"];
|
||||
|
||||
gClient.addListener("paused", function tester(aEvent, aPacket) {
|
||||
is(aPacket.why.type, "pauseOnDOMEvents",
|
||||
"A hidden breakpoint was hit.");
|
||||
|
||||
is(aPacket.frame.where.line, 15, "Found the load event listener.");
|
||||
gClient.removeListener("paused", tester);
|
||||
deferred.resolve();
|
||||
|
||||
gThreadClient.resume(() => triggerButtonClick(handlers.slice(-1)));
|
||||
});
|
||||
|
||||
getTabActorForUrl(gClient, TAB_URL).then(aGrip => {
|
||||
gClient.attachTab(aGrip.actor, (aResponse, aTabClient) => {
|
||||
aTabClient.reload();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function triggerButtonClick() {
|
||||
let button = content.document.querySelector("button");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, button);
|
||||
}
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
gClient = null;
|
||||
gThreadClient = null;
|
||||
});
|
@ -1,55 +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/ */
|
||||
|
||||
/**
|
||||
* Test that event listeners are properly fetched even if one of the listeners
|
||||
* don't have a Debugger.Source object (bug 942899).
|
||||
*
|
||||
* This test is skipped on debug and e10s builds for following reasons:
|
||||
* - debug: requiring sdk/tabs causes memory leaks when new windows are opened
|
||||
* in tests executed after this one. Bug 1142597.
|
||||
* - e10s: tab.attach is not e10s safe and only works when add-on compatibility
|
||||
* shims are in place. Bug 1146603.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_event-listeners-01.html";
|
||||
|
||||
function test() {
|
||||
Task.spawn(function* () {
|
||||
let tab = yield addTab(TAB_URL);
|
||||
|
||||
// Create a sandboxed content script the Add-on SDK way. Inspired by bug
|
||||
// 1145996.
|
||||
let tabs = require("sdk/tabs");
|
||||
let sdkTab = [...tabs].find(tab => tab.url === TAB_URL);
|
||||
ok(sdkTab, "Add-on SDK found the loaded tab.");
|
||||
|
||||
info("Attaching an event handler via add-on sdk content scripts.");
|
||||
let worker = sdkTab.attach({
|
||||
contentScript: "document.body.addEventListener('click', e => alert(e))",
|
||||
onError: ok.bind(this, false)
|
||||
});
|
||||
|
||||
let options = {
|
||||
source: TAB_URL,
|
||||
line: 1
|
||||
};
|
||||
let [,, panel, win] = yield initDebugger(tab, options);
|
||||
let dbg = panel.panelWin;
|
||||
let controller = dbg.DebuggerController;
|
||||
let constants = dbg.require("./content/constants");
|
||||
let actions = dbg.require("./content/actions/event-listeners");
|
||||
let fetched = waitForDispatch(panel, constants.FETCH_EVENT_LISTENERS);
|
||||
|
||||
info("Scheduling event listener fetch.");
|
||||
controller.dispatch(actions.fetchEventListeners());
|
||||
|
||||
info("Waiting for updated event listeners to arrive.");
|
||||
yield fetched;
|
||||
|
||||
ok(true, "The listener update did not hang.");
|
||||
closeDebuggerAndFinish(panel);
|
||||
});
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Debugger test page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<button>Click me!</button>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.addEventListener("load", function onload() {
|
||||
var button = document.querySelector("button");
|
||||
button.onclick = function () {
|
||||
debugger;
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -4,10 +4,9 @@
|
||||
|
||||
/* globals dump */
|
||||
|
||||
const { Cu } = require("chrome");
|
||||
const { BrowserTestUtils } = Cu.import("resource://testing-common/BrowserTestUtils.jsm", {});
|
||||
const Services = require("Services");
|
||||
const tabs = require("sdk/tabs");
|
||||
const tabUtils = require("sdk/tabs/utils");
|
||||
const { viewFor } = require("sdk/view/core");
|
||||
const { waitForDelayedStartupFinished } = require("devtools/client/performance/test/helpers/wait-utils");
|
||||
const { gDevTools } = require("devtools/client/framework/devtools");
|
||||
|
||||
@ -29,44 +28,19 @@ exports.addTab = function ({ url, win }, options = {}) {
|
||||
|
||||
dump(`Adding tab with url: ${url}.\n`);
|
||||
|
||||
return new Promise(resolve => {
|
||||
let tab;
|
||||
|
||||
tabs.on("ready", function onOpen(model) {
|
||||
if (tab != viewFor(model)) {
|
||||
return;
|
||||
}
|
||||
dump(`Tab added and finished loading: ${model.url}.\n`);
|
||||
tabs.off("ready", onOpen);
|
||||
resolve(tab);
|
||||
});
|
||||
|
||||
win.focus();
|
||||
tab = tabUtils.openTab(win, url);
|
||||
|
||||
if (options.dontWaitForTabReady) {
|
||||
resolve(tab);
|
||||
}
|
||||
});
|
||||
let { gBrowser } = win || window;
|
||||
return BrowserTestUtils.openNewForegroundTab(gBrowser, url,
|
||||
!options.dontWaitForTabReady);
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a browser tab from the specified window and waits for it to close.
|
||||
*/
|
||||
exports.removeTab = function (tab, options = {}) {
|
||||
dump(`Removing tab: ${tabUtils.getURI(tab)}.\n`);
|
||||
dump(`Removing tab: ${tab.linkedBrowser.currentURI.spec}.\n`);
|
||||
|
||||
return new Promise(resolve => {
|
||||
tabs.on("close", function onClose(model) {
|
||||
if (tab != viewFor(model)) {
|
||||
return;
|
||||
}
|
||||
dump(`Tab removed and finished closing: ${model.url}.\n`);
|
||||
tabs.off("close", onClose);
|
||||
resolve(tab);
|
||||
});
|
||||
|
||||
tabUtils.closeTab(tab);
|
||||
BrowserTestUtils.removeTab(tab).then(() => resolve(tab));
|
||||
|
||||
if (options.dontWaitForTabClose) {
|
||||
resolve(tab);
|
||||
|
@ -6,9 +6,7 @@
|
||||
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
loader.lazyRequireGetter(this, "getBrowserForTab", "sdk/tabs/utils", true);
|
||||
|
||||
const getTargetId = ({tab}) => getBrowserForTab(tab).outerWindowID;
|
||||
const getTargetId = ({tab}) => tab.linkedBrowser.outerWindowID;
|
||||
const enabledCommands = new Map();
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user