Bug 1443923 - part1: Return script location for shadow host in NodeActor form;r=bgrins
MozReview-Commit-ID: CLmOqqAa123
--- a/devtools/server/actors/inspector/node.js
+++ b/devtools/server/actors/inspector/node.js
@@ -121,16 +121,17 @@ const NodeActor = protocol.ActorClassWit
displayType: this.displayType,
// doctype attributes
name: this.rawNode.name,
publicId: this.rawNode.publicId,
systemId: this.rawNode.systemId,
attrs: this.writeAttrs(),
+ customElementLocation: this.getCustomElementLocation(),
isBeforePseudoElement: isBeforePseudoElement(this.rawNode),
isAfterPseudoElement: isAfterPseudoElement(this.rawNode),
isAnonymous: isAnonymous(this.rawNode),
isNativeAnonymous: isNativeAnonymous(this.rawNode),
isXBLAnonymous: isXBLAnonymous(this.rawNode),
isShadowAnonymous: isShadowAnonymous(this.rawNode),
isShadowRoot: shadowRoot,
shadowRootMode: getShadowRootMode(this.rawNode),
@@ -346,16 +347,46 @@ const NodeActor = protocol.ActorClassWit
listenerArray.sort((a, b) => {
return a.type.localeCompare(b.type);
});
return listenerArray;
},
/**
+ * Retrieve the script location of the custom element definition for this node, when
+ * relevant. To be linked to a custom element definition
+ */
+ getCustomElementLocation: function() {
+ // Get a reference to the custom element definition function.
+ const name = this.rawNode.localName;
+
+ const customElementsRegistry = this.rawNode.ownerGlobal.customElements;
+ const customElement = customElementsRegistry && customElementsRegistry.get(name);
+ if (!customElement) {
+ return undefined;
+ }
+ // Create debugger object for the customElement function.
+ const global = Cu.getGlobalForObject(customElement);
+ const dbg = this.parent().targetActor.makeDebugger();
+ const globalDO = dbg.addDebuggee(global);
+ const customElementDO = globalDO.makeDebuggeeValue(customElement);
+
+ // Return undefined if we can't find a script for the custom element definition.
+ if (!customElementDO.script) {
+ return undefined;
+ }
+
+ return {
+ url: customElementDO.script.url,
+ line: customElementDO.script.startLine,
+ };
+ },
+
+ /**
* Process a handler
*
* @param {Node} node
* The node for which we want information.
* @param {Array} listenerArray
* listenerArray contains all event objects that we have gathered
* so far.
* @param {Debugger} dbg
--- a/devtools/shared/fronts/node.js
+++ b/devtools/shared/fronts/node.js
@@ -314,16 +314,20 @@ const NodeFront = FrontClassWithSpec(nod
get shadowRootMode() {
return this._form.shadowRootMode;
},
get isShadowHost() {
return this._form.isShadowHost;
},
+ get customElementLocation() {
+ return this._form.customElementLocation;
+ },
+
get isDirectShadowHostChild() {
return this._form.isDirectShadowHostChild;
},
// doctype properties
get name() {
return this._form.name;
},