forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backed out changeset 4c2036f901c1 (bug 1353042) for build bustage in …
…Symlink target path does not exist: doc_event-listeners-04.html CLOSED TREE
- Loading branch information
Showing
6 changed files
with
216 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
devtools/client/debugger/test/mochitest/browser_dbg_break-on-dom-event-03.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); |
55 changes: 55 additions & 0 deletions
55
devtools/client/debugger/test/mochitest/browser_dbg_event-listeners-04.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
23 changes: 23 additions & 0 deletions
23
devtools/client/debugger/test/mochitest/doc_event-listeners-04.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters