Skip to content

Commit

Permalink
Bug 1538397 - Don't use source actor for event listeners with mapped …
Browse files Browse the repository at this point in the history
…sources, r=ochameau.

--HG--
extra : histedit_source : ff5792d263f849c3a8255371e5570cd842f02a05%2C2fba09ffff23dd9d0901aaabad74c6a1708a30da
  • Loading branch information
bhackett1024 committed Mar 28, 2019
1 parent 1f1d943 commit 199bb29
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
2 changes: 2 additions & 0 deletions devtools/client/inspector/markup/test/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ support-files =
doc_markup_xul.xul
doc_markup_update-on-navigtion_1.html
doc_markup_update-on-navigtion_2.html
doc_markup_view-original-source.html
events_bundle.js
events_bundle.js.map
events_original.js
Expand Down Expand Up @@ -241,6 +242,7 @@ skip-if = (os == 'win' && processor == 'aarch64') # bug 1533507
[browser_markup_toggle_closing_tag_line.js]
[browser_markup_update-on-navigtion.js]
[browser_markup_view-source.js]
[browser_markup_view-original-source.js]
[browser_markup_void_elements_html.js]
[browser_markup_void_elements_xhtml.js]
[browser_markup_whitespace.js]
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* -*- 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/ */

"use strict";

const TEST_URI = URL_ROOT + "doc_markup_view-original-source.html";

// Test that event handler links go to the right debugger source when the
// event handler is source mapped.
add_task(async function() {
const { inspector, toolbox } = await openInspectorForURL(TEST_URI);

const target = await TargetFactory.forTab(gBrowser.selectedTab);

const nodeFront = await getNodeFront("#foo", inspector);
const container = getContainerForNodeFront(nodeFront, inspector);

const evHolder = container.elt.querySelector(
".inspector-badge.interactive[data-event]");

evHolder.scrollIntoView();
EventUtils.synthesizeMouseAtCenter(evHolder, {},
inspector.markup.doc.defaultView);

const tooltip = inspector.markup.eventDetailsTooltip;
await tooltip.once("shown");
await tooltip.once("event-tooltip-source-map-ready");

const debuggerIcon = tooltip.panel.querySelector(".event-tooltip-debugger-icon");
EventUtils.synthesizeMouse(debuggerIcon, 2, 2, {}, debuggerIcon.ownerGlobal);

await gDevTools.showToolbox(target, "jsdebugger");
const dbg = toolbox.getPanel("jsdebugger");

let source;
await BrowserTestUtils.waitForCondition(() => {
source = dbg._selectors.getSelectedSource(dbg._getState());
return !!source;
}, "loaded source", 100, 20);

is(
source.url,
"webpack:///events_original.js",
"expected original source to be loaded"
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<body>
<button id="foo">Button</button>
<script src="events_bundle.js"></script>
<script>
"use strict";
var button = document.getElementById("foo");
button.addEventListener("click", window.init);
</script>
</body>
4 changes: 3 additions & 1 deletion devtools/client/shared/view-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ exports.viewSourceInStyleEditor = async function(toolbox, sourceURL,

/**
* Tries to open a JavaScript file in the Debugger. If the file is not found,
* it is opened in source view instead.
* it is opened in source view instead. Either the source URL or source actor ID
* can be specified. If both are specified, the source actor ID is used.
*
* Returns a promise resolving to a boolean indicating whether or not
* the source was able to be displayed in the Debugger, as the built-in Firefox
* View Source is the fallback.
Expand Down
5 changes: 5 additions & 0 deletions devtools/client/shared/widgets/tooltip/EventTooltipHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ EventTooltip.prototype = {
const eventEditor = this._eventEditors.get(content);
eventEditor.uri = newURI;

// Since we just changed the URI/line, we need to clear out the
// source actor ID. These must be consistent with each other when
// we call viewSourceInDebugger with the event's information.
eventEditor.sourceActor = null;

// This is emitted for testing.
this._tooltip.emit("event-tooltip-source-map-ready");
}
Expand Down

0 comments on commit 199bb29

Please sign in to comment.