michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: const { data } = require("sdk/self"); michael@0: const { Symbiont } = require("sdk/deprecated/symbiont"); michael@0: michael@0: exports["test:direct communication with trusted document"] = function(assert, done) { michael@0: let worker = Symbiont({ michael@0: contentURL: data.url("test-trusted-document.html") michael@0: }); michael@0: michael@0: worker.port.on('document-to-addon', function (arg) { michael@0: assert.equal(arg, "ok", "Received an event from the document"); michael@0: worker.destroy(); michael@0: done(); michael@0: }); michael@0: worker.port.emit('addon-to-document', 'ok'); michael@0: }; michael@0: michael@0: exports["test:`addon` is not available when a content script is set"] = function(assert, done) { michael@0: let worker = Symbiont({ michael@0: contentURL: data.url("test-trusted-document.html"), michael@0: contentScript: "new " + function ContentScriptScope() { michael@0: self.port.emit("cs-to-addon", "addon" in unsafeWindow); michael@0: } michael@0: }); michael@0: michael@0: worker.port.on('cs-to-addon', function (hasAddon) { michael@0: assert.equal(hasAddon, false, michael@0: "`addon` is not available"); michael@0: worker.destroy(); michael@0: done(); michael@0: }); michael@0: }; michael@0: michael@0: require("sdk/test/runner").runTestsFromModule(module);