Skip to content

Loading…

Bug 786305 - Expose ChromeWorker via chrome module. #537

Merged
merged 2 commits into from

2 participants

@Gozala
Mozilla member

No description provided.

@ochameau ochameau was assigned
@ochameau
Mozilla member

Could you add some simple tests to ensure that it does work?

@ochameau
Mozilla member

r+

@ochameau ochameau merged commit e5cf073 into mozilla:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 28, 2012
  1. @Gozala
Commits on Aug 30, 2012
  1. @Gozala

    Write tests for ChromeWorker.

    Gozala committed
View
6 packages/api-utils/lib/loader.js
@@ -347,7 +347,11 @@ const Loader = iced(function Loader(options) {
'@loader/unload': destructor,
'@loader/options': options,
'chrome': { Cc: Cc, Ci: Ci, Cu: Cu, Cr: Cr, Cm: Cm,
- CC: bind(CC, Components), components: Components }
+ CC: bind(CC, Components), components: Components,
+ // Note: Exporting `ChromeWorker` does not works, probably
+ // because platform does some sandbox incompatible scope
+ // sniffing .
+ ChromeWorker: function(uri) { return new ChromeWorker(uri) }}
}, modules);
modules = keys(modules).reduce(function(result, id) {
View
8 packages/api-utils/tests/fixtures/chrome-worker.js
@@ -0,0 +1,8 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+'use strict';
+
+postMessage('Hello');
View
23 packages/api-utils/tests/test-chrome.js
@@ -0,0 +1,23 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+'use strict';
+
+let chrome = require('chrome');
+
+
+exports['test ChromeWorker'] = function(assert, done) {
+ let uri = module.uri.substr(0, module.uri.lastIndexOf('/') + 1) +
+ 'fixtures/chrome-worker.js';
+
+ let worker = new chrome.ChromeWorker(uri);
+ worker.addEventListener('message', function(event) {
+ assert.equal(event.data, 'Hello', 'message received');
+ worker.terminate();
+ done();
+ });
+};
+
+require('test').run(exports);
Something went wrong with that request. Please try again.