Closed Bug 1694057 Opened 4 years ago Closed 4 years ago

webExtensions, getAllFrames returns "about:blank" for empty src iframes

Categories

(WebExtensions :: Untriaged, defect)

Firefox 86
defect

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: a.minyukovich, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:86.0) Gecko/20100101 Firefox/86.0

Steps to reproduce:

calling browser.webNavigation.getAllFrames returns a list of objects representing iframes. Some iframes have an empty src, which getAllFrames shows as "about:blank", while a content script sees them as empty strings (looking at the 'src' attribute of iframe nodes).

Expected results:

Some sort of consistency, either both about:blank or both empty strings.

I realize this is a rather minor issue, but still thought to report. Use case: trying to match iframes returned by browser.webNavigation.getAllFrames with the iframes found by a parent-page content script, by matching iframe urls/src.

Hi Will,

Do you have a test case so that we can reproduce this issue, please?

Thanks in advance, Flor.

Flags: needinfo?(a.minyukovich)
Product: Firefox → WebExtensions

Hello,

I’m from WebExtensions QA and I’m attempting to confirm the issue. If possible, I would require the add-on you used when you encountered the issue as well as some more detailed steps to reproduce, as asked by Flor in Comment 1.
Thank you !

The webNavigation API reports the URL of the frame. Even if an empty src is used (or if src is not set at all), the URL is still implicitly about:blank. Use location.href in the frame and you'll see the same result.

If you are interested in the src attribute of the frame, insert a content script, get the frame element using frameElement global and then you can read the src attribute off it.

Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Flags: needinfo?(a.minyukovich)
Resolution: --- → INVALID

You are probably right to close it. I thought the following should have been true: frameElement.src === location.href, but now realize it doesn't have to. I might file an enhancement request instead, as I needed to ensure the non-iframe main-window content script and background extension script could uniquely identify/refer to iframes, and the only info content/background scripts seemed to share was iframes' src/href (which is a problem if several iframes have the same src). Thx.

If you use the runtime.sendMessage API from a content script, then the background script with the runtime.onMessage listener can uniquely identify the frame by the tabId (via tab.id) + frameId properties of the sender parameter (the second argument of onMessage, or a port.sender property on the runtime.onConnect event).

You need to log in before you can comment on or make changes to this bug.