Closed Bug 1675725 Opened 4 years ago Closed 4 years ago

self.Symbol.for is undefined in a content script within a webextension

Categories

(WebExtensions :: Untriaged, defect)

Firefox 82
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1208775

People

(Reporter: me, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0

Steps to reproduce:

Add the following statements to the content script of a webextension:
console.info(self.Symbol is, self.Symbol)
console.info(self.Symbol.for is, self.Symbol.for)

Actual results:

self.Symbol is defined and has a "for" property, but self.Symbol.for is undefined. Please see the screenshot attached.

The problem arises only in the content script, it works perfectly within the background script. Also, the problem affects only self.Symbol.for, Symbol.for is defined.

Expected results:

self.Symbol.for should be a function.

Hi Kirlat,
Is there any way you could share a reduced test case for this issue? I'm moving it over to a component in the meantime so developers can also check it out.

Component: Untriaged → Console
Flags: needinfo?(kirlat)
Product: Firefox → DevTools

Is there any way you could share a reduced test case for this issue? I'm moving it over to a component in the meantime so developers can also check it out.

I will try to provide it soon.

Flags: needinfo?(kirlat)

I was able to reproduce in one of my webextension.
I checked that it wasn't an issue with the console by calling alert("" + self.Symbol.for), which does show the alert with undefined in it (if I do alert("" + Symbol.for), I do see the stringified native function).

For what it's worth, globalThis.Symbol.for works as intended.

Status: UNCONFIRMED → NEW
Component: Console → Untriaged
Ever confirmed: true
Product: DevTools → WebExtensions

The issue here is that you're trying to access symbols from a different (page's) global. globalThis gets you the global of your content script. This is basically bug 1208775.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: