Basic functions/object are missed from iframe contentWindow when accessing from content script.

UNCONFIRMED
Unassigned

Status

()

Core
DOM
UNCONFIRMED
2 years ago
2 years ago

People

(Reporter: oleksii.levzhynskyi, Unassigned)

Tracking

44 Branch
Unspecified
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: btpp-followup-2016-03-11)

Attachments

(1 attachment)

(Reporter)

Description

2 years ago
Created attachment 8721945 [details]
parseInt.zip

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36

Steps to reproduce:

I have found strange issue with iframe's contentWindow when I work with it from addon's content script.

* Unpack parseInt.zip
* see data/parse-int.js
* Run addon: 'jpm run'
* Open any site and web inspector
* See console errors


Actual results:

Basic objects/functions are missed from content script

Console output:
Ola!
>> parseInt null
>> Math Object {  }


Expected results:

Basic objects/functions should be present
(Reporter)

Updated

2 years ago
OS: Unspecified → Mac OS X
(Reporter)

Updated

2 years ago
Summary: Basic functions/object missed from iframe contentWindow when accessing from content script. → Basic functions/object are missed from iframe contentWindow when accessing from content script.

Updated

2 years ago
Component: Untriaged → DOM
Product: Firefox → Core
This feels like some sort of intentional security-related restriction.

Can you clarify what you mean by "content script"
Flags: needinfo?(oleksii.levzhynskyi)
Whiteboard: btpp-followup-2016-03-01
(Reporter)

Comment 2

2 years ago
(In reply to Andrew Overholt [:overholt] from comment #1)
> This feels like some sort of intentional security-related restriction.
> 
> Can you clarify what you mean by "content script"

I meant "content script" - the script added to tab via pageMod.PageMod({contentScriptFile: '...'})
Flags: needinfo?(oleksii.levzhynskyi)
Andy, is this an add-on SDK issue?
Flags: needinfo?(amckay)
Whiteboard: btpp-followup-2016-03-01 → btpp-followup-2016-03-04
Maybe Kris knows.
Flags: needinfo?(kmaglione+bmo)
Whiteboard: btpp-followup-2016-03-04 → btpp-followup-2016-03-11
It's because the window object that you get is an X-Ray wrapper, and X-Ray wrappers don't reflect functions that aren't present on the native prototype. Unlike many of the properties of windows, functions like `parseInt` are part of the core JavaScript spec (rather than the DOM spec), so they're provided by the JS engine directly, and available on every global.

I'm not sure about some of the details here (e.g., why exactly `parseInt` is not available, but `Number` is), but there shouldn't be any reason to access those functions via a content window rather than calling them directly.
Flags: needinfo?(kmaglione+bmo)

Updated

2 years ago
Flags: needinfo?(amckay)
You need to log in before you can comment on or make changes to this bug.