Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "Bug 616779 - it isn't possible to postMessage to widget's con…

…tent scripts."

This reverts commit 25cd205.
  • Loading branch information...
commit 33d5ce22bff0b66070f5a4ca13060b098635dc05 1 parent 3202d44
@mykmelez mykmelez authored
View
12 packages/addon-kit/docs/widget.md
@@ -144,18 +144,6 @@ create your content scripts in separate files and pass their URLs using the
myWidget.width += 10;
}, 1000);
- // A widget communicating bi-directionally with a content script.
- let widget = widgets.Widget({
- label: "bi-directional communication!",
- content: "<foo>bar</foo>",
- contentScriptWhen: "ready",
- contentScript: "this.onMessage = function(message) { alert('got message!'); }; postMessage('ready');",
- onMessage: function(message) {
- if (message.data == "ready")
- widget.postMessage(origMessage);
- }
- });
-
<api-name="Widget">
@class
Represents a widget object.
View
7 packages/addon-kit/lib/widget.js
@@ -201,10 +201,6 @@ const Widget = Trait.compose(Loader, Trait.compose({
},
_panel: null,
- postMessage: function Widget_postMessage(message) {
- browserManager.updateItem(this._public, "postMessage", message);
- },
-
destroy: function Widget_destroy() {
browserManager.removeItem(this._public);
}
@@ -410,9 +406,6 @@ BrowserWindow.prototype = {
case "tooltip":
item.node.setAttribute("tooltiptext", value);
break;
- case "postMessage":
- item.symbiont.postMessage(value);
- break;
}
}
},
View
26 packages/addon-kit/tests/test-widget.js
@@ -72,8 +72,10 @@ exports.testConstructor = function(test) {
"No content or contentURL property found. Widgets must have one or the other.",
"throws on empty content");
- // Helper for testing a single widget.
- // Confirms proper addition and content setup.
+ /**
+ * Helper for testing a single widget.
+ * Confirms proper addition and content setup.
+ */
function testSingleWidget(widgetOptions) {
let startCount = widgetCount();
let widget = widgets.Widget(widgetOptions);
@@ -493,26 +495,6 @@ exports.testPanelWidget3 = function testPanelWidget3(test) {
test.waitUntilDone();
};
-exports.testWidgetMessaging = function testPanelWidgetMessaging(test) {
- test.waitUntilDone();
- let origMessage = "foo";
- const widgets = require("widget");
- let widget = widgets.Widget({
- label: "foo",
- content: "<bar>baz</bar>",
- contentScriptWhen: "ready",
- contentScript: "this.onMessage = function(data) { postMessage(data); }; postMessage('ready');",
- onMessage: function(message) {
- if (message.data == "ready")
- widget.postMessage(origMessage);
- else {
- test.assertEqual(origMessage, message.data);
- test.done();
- }
- }
- });
-};
-
/******************* helpers *********************/
// Helper for calling code at window close
View
13 packages/api-utils/docs/content/worker.md
@@ -32,12 +32,13 @@ that occurs in one of the content scripts.
**Example**
- const workers = require("content/worker");
- let worker = workers.Worker({
- window: require("window-utils").activeWindow,
- contentScript: "self.onMessage = function(data) { " +
- " postMessage(window.location + ': Hi ' + data.name); " +
- "};",
+ let worker = Worker({
+ window: myWindow,
+ contentScript: 'new ' + function WorkerGlobalScope() {
+ self.on('message', function onMessage(data) {
+ postMessage(window.location + ': Hi ' + data.name);
+ })
+ },
onMessage: function(msg) {
console.log(msg);
}
View
2  packages/api-utils/lib/content/worker.js
@@ -189,7 +189,7 @@ const WorkerGlobalScope = AsyncEventEmitter.compose({
configurable: true
},
console: { value: console, configurable: true },
- });
+ });
// Chain the global object for the sandbox to the global object for
// the frame. This supports JavaScript libraries like jQuery that depend
// on the presence of certain properties in the global object, like window,
Please sign in to comment.
Something went wrong with that request. Please try again.