Skip to content

Commit

Permalink
Backed out changeset 4c2036f901c1 (bug 1353042) for build bustage in …
Browse files Browse the repository at this point in the history
…Symlink target path does not exist: doc_event-listeners-04.html

CLOSED TREE
  • Loading branch information
IrisHsiao committed May 23, 2017
1 parent 399614a commit ad000bc
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 8 deletions.
5 changes: 5 additions & 0 deletions devtools/client/debugger/test/mochitest/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ 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
Expand Down Expand Up @@ -181,6 +182,8 @@ 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]
Expand Down Expand Up @@ -266,6 +269,8 @@ 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]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/* -*- 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;
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* -*- 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);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- 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>
40 changes: 33 additions & 7 deletions devtools/client/performance/test/helpers/tab-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

/* 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");

Expand All @@ -28,19 +29,44 @@ exports.addTab = function ({ url, win }, options = {}) {

dump(`Adding tab with url: ${url}.\n`);

let { gBrowser } = win || window;
return BrowserTestUtils.openNewForegroundTab(gBrowser, url,
!options.dontWaitForTabReady);
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);
}
});
};

/**
* Removes a browser tab from the specified window and waits for it to close.
*/
exports.removeTab = function (tab, options = {}) {
dump(`Removing tab: ${tab.linkedBrowser.currentURI.spec}.\n`);
dump(`Removing tab: ${tabUtils.getURI(tab)}.\n`);

return new Promise(resolve => {
BrowserTestUtils.removeTab(tab).then(() => resolve(tab));
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);

if (options.dontWaitForTabClose) {
resolve(tab);
Expand Down
4 changes: 3 additions & 1 deletion devtools/shared/gcli/command-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

const EventEmitter = require("devtools/shared/event-emitter");

const getTargetId = ({tab}) => tab.linkedBrowser.outerWindowID;
loader.lazyRequireGetter(this, "getBrowserForTab", "sdk/tabs/utils", true);

const getTargetId = ({tab}) => getBrowserForTab(tab).outerWindowID;
const enabledCommands = new Map();

/**
Expand Down

0 comments on commit ad000bc

Please sign in to comment.