Bug 1517626 - Treat event handlers as eval'ed sources, r=lsmyth.

This commit is contained in:
Brian Hackett 2019-01-10 16:53:11 -10:00
parent 7972421862
commit 4110ee1e5e
4 changed files with 33 additions and 4 deletions

View File

@ -654,6 +654,7 @@ support-files =
examples/times2.js
examples/doc-windowless-workers.html
examples/simple-worker.js
examples/doc-event-handler.html
examples/doc-eval-throw.html
examples/doc_rr_basic.html
examples/doc_rr_continuous.html
@ -772,6 +773,7 @@ skip-if = os == "win"
[browser_dbg-wasm-sourcemaps.js]
skip-if = true
[browser_dbg-windowless-workers.js]
[browser_dbg-event-handler.js]
[browser_dbg-eval-throw.js]
[browser_dbg_rr_breakpoints-01.js]
skip-if = os != "mac" || debug || !nightly_build

View File

@ -0,0 +1,17 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that pausing within an event handler on an element does *not* show the
// HTML page containing that element. It should show a sources tab containing
// just the handler's text instead.
add_task(async function() {
const dbg = await initDebugger("doc-event-handler.html");
invokeInTab("synthesizeClick");
await waitForPaused(dbg);
const state = dbg.store.getState();
const source = dbg.selectors.getSelectedSource(state);
ok(!source.url, "Selected source should not have a URL");
});

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<meta charset=UTF-8>
<script>
function synthesizeClick() {
const elem = document.getElementById("clicky");
const event = new MouseEvent("click", {});
elem.dispatchEvent(event);
}
</script>
<span onclick="debugger" id="clicky">click me</span>

View File

@ -93,7 +93,7 @@ TabSources.prototype = {
// HTML page. The actor representing this fake HTML source is
// stored in this array, which always has a URL, so check it
// first.
if (source.url in this._htmlDocumentSourceActors) {
if (isInlineSource && source.url in this._htmlDocumentSourceActors) {
return this._htmlDocumentSourceActors[source.url];
}
@ -234,10 +234,10 @@ TabSources.prototype = {
// sources. Otherwise, use the `originalUrl` property to treat it
// as an HTML source that manages multiple inline sources.
// Assume the source is inline if the element that introduced it is not a
// script element, or does not have a src attribute.
// Assume the source is inline if the element that introduced it is a
// script element and does not have a src attribute.
const element = source.element ? source.element.unsafeDereference() : null;
if (element && (element.tagName !== "SCRIPT" || !element.hasAttribute("src"))) {
if (element && element.tagName === "SCRIPT" && !element.hasAttribute("src")) {
if (source.introductionScript) {
// As for other evaluated sources, script elements which were
// dynamically generated when another script ran should have