diff --git a/remote/domains/content/DOM.jsm b/remote/domains/content/DOM.jsm index f52dfb518463..a771dfbffb15 100644 --- a/remote/domains/content/DOM.jsm +++ b/remote/domains/content/DOM.jsm @@ -78,6 +78,11 @@ class DOM extends ContentProcessDomain { } } + let context = this.docShell.browsingContext; + if (unsafeObj instanceof HTMLIFrameElement) { + context = unsafeObj.contentWindow.docShell.browsingContext; + } + const node = { nodeId: debuggerObj.nodeId, backendNodeId: debuggerObj.nodeId, @@ -87,7 +92,7 @@ class DOM extends ContentProcessDomain { nodeValue: unsafeObj.nodeValue ? unsafeObj.nodeValue.toString() : "", childNodeCount: unsafeObj.childElementCount, attributes: attributes.length > 0 ? attributes : undefined, - frameId: this.docShell.browsingContext.id.toString(), + frameId: context.id.toString(), }; return { node }; diff --git a/remote/test/browser/dom/browser_describeNode.js b/remote/test/browser/dom/browser_describeNode.js index bb354ae6ab46..931b908dfd21 100644 --- a/remote/test/browser/dom/browser_describeNode.js +++ b/remote/test/browser/dom/browser_describeNode.js @@ -4,6 +4,7 @@ "use strict"; const DOC = toDataURL("

foo

bar

"); +const DOC_FRAME = toDataURL(``); add_task(async function objectIdInvalidTypes({ client }) { const { DOM } = client; @@ -146,3 +147,29 @@ add_task(async function objectIdDoesNotChangeForTheSameNode({ client }) { is(node1[prop], node2[prop], `Values of ${prop} are equal`); } }); + +add_task(async function frameIdForFrameElement({ client }) { + const { DOM, Page, Runtime } = client; + + await Page.enable(); + + const frameAttached = Page.frameAttached(); + await loadURL(DOC_FRAME); + const { frameId, parentFrameId } = await frameAttached; + + await Runtime.enable(); + + const { result: frameObj } = await Runtime.evaluate({ + expression: "document.getElementsByTagName('iframe')[0]", + }); + const { node: frame } = await DOM.describeNode({ + objectId: frameObj.objectId, + }); + + is(frame.frameId, frameId, "Reported frameId is from the frame itself"); + isnot( + frame.frameId, + parentFrameId, + "Reported frameId is not the parentFrameId" + ); +});