Closed
Bug 1288594
Opened 9 years ago
Closed 9 years ago
cloneInto not defined in Web Extensions ContentScript
Categories
(addons.mozilla.org :: Security, defect)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: brocktaylor87, Unassigned)
Details
(Whiteboard: [specification][type:bug])
What did you do?
================
1. I attempted to use the cloneInto() function in a contentscript while writing my web extension.
2. I also tried to use Components.utils.cloneInto()
What happened?
==============
It throws a reference exception saying cloneInto is undefined. This is causing a same origin issue that is breaking the functionality of my web extension.
What should have happened?
==========================
According to this document:
https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts/Interacting_with_page_scripts#Expose_objects_to_page_scripts
cloneInto() should be a global function available in all contentScripts
Is there anything else we should know?
======================================
| Reporter | ||
Updated•9 years ago
|
Component: BrowserCompat → Security
Product: Mozilla Developer Network → addons.mozilla.org
Hardware: All → Unspecified
Comment 1•9 years ago
|
||
Are you talking about webextensions or the Add-on SDK? In webextensions there is no cloneInto(). In SDK extensions, there is and it's likely an issue in your code somwhere. Please direct development related questions to http://discourse.mozilla-community.org/c/add-ons/
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
Comment 2•9 years ago
|
||
In bug 1280482, which should be landing soon in nightly, access to some of those content helpers are now available to WebExtensions as well.
| Reporter | ||
Comment 3•9 years ago
|
||
I actually discovered that the page script does have access to the object that was being created, but that it restricts it in an odd fashion. Here's what I've done.
Create and dispatch an event in the content script:
var eventData = {
"detail: {
"data": customEventData
}
}
var event = new CustomEvent(eventName, eventData);
document.dispatchEvent(event);
Then I listen for the event in a script that runs in the extension on the page:
document.addEventListener("customEventName", function (message) {
var dataPassedFromEvent = message.detail.data;
});
When I do this, I have access to and can log message.detail to the console and it shows "Object { data: "data" }" But if I try to console.log(message.detail.data) it throws the error that I don't have permission to access the property "data".
I resolved this in my extension by simply removing the "detail" object and just referring to message.data, but it doesn't make sense that it would block one but not the other.
Let me know if you need more information for that to be clear. Thanks.
You need to log in
before you can comment on or make changes to this bug.
Description
•