Closed Bug 1567699 Opened 5 years ago Closed 5 years ago

JavaScript Proxy object name does not match name of wrapped object

Categories

(Core :: JavaScript Engine, defect)

69 Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1277799

People

(Reporter: alexander-mozilla, Unassigned)

References

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

Steps to reproduce:

Open a JS console and compare the output of these two snippets:

Object.prototype.toString.call(window)
Object.prototype.toString.call(new Proxy(window, {}))

Actual results:

The first snippet produces the string "[object Window]", the second snippet produces the string "[object Object]".

Expected results:

They both should return "[object Window]" as an JS proxy should be maximally transparent to script using it.

Depends on: 1277799

@ntninja, if you're interested, follow bug 1277799.

The standard for Object.prototype.toString is awkwardly worded, but it boils down to:

  • Try getting the property obj[Symbol.toStringTag] (step 15). If that is defined, use it.
  • Otherwise, use the builtinTag computed in steps 4-14. For Window objects, this is "Object".

Note that the standard actually requires proxies to be treated non-transparently in steps 4-14. (Proxy policy is delicate business...)

However, the good news is that obj[Symbol.toStringTag] should be defined on Window and other DOM objects, according to the WebIDL standard. We just aren't doing that yet.

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