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: "use strict"; michael@0: michael@0: const { create: makeFrame } = require("sdk/frame/utils"); michael@0: const { window } = require("sdk/addon/window"); michael@0: const { Loader } = require('sdk/test/loader'); michael@0: const loader = Loader(module); michael@0: const Worker = loader.require("sdk/content/worker").Worker; michael@0: michael@0: exports.testMembranelessMode = function(assert, done) { michael@0: michael@0: let url = "data:text/html;charset=utf-8," + encodeURIComponent( michael@0: '' michael@0: ); michael@0: michael@0: let element = makeFrame(window.document, { michael@0: nodeName: "iframe", michael@0: type: "content", michael@0: allowJavascript: true, michael@0: allowPlugins: true, michael@0: allowAuth: true, michael@0: uri: url michael@0: }); michael@0: michael@0: element.addEventListener("DOMContentLoaded", onDOMReady, false); michael@0: michael@0: function onDOMReady() { michael@0: let worker = Worker({ michael@0: window: element.contentWindow, michael@0: contentScript: michael@0: 'new ' + function () { michael@0: var assert = function assert(v, msg) { michael@0: self.port.emit("assert", { assertion: v, msg: msg }); michael@0: } michael@0: var done = function done() { michael@0: self.port.emit("done"); michael@0: } michael@0: window.wrappedJSObject.fuu = { bar: 42 }; michael@0: window.wrappedJSObject.assert = assert; michael@0: window.wrappedJSObject.runTest(); michael@0: done(); michael@0: } michael@0: }); michael@0: worker.port.on("done", function () { michael@0: element.parentNode.removeChild(element); michael@0: done(); michael@0: }); michael@0: worker.port.on("assert", function (data) { michael@0: assert.ok(data.assertion, data.msg); michael@0: }); michael@0: } michael@0: }; michael@0: michael@0: require("sdk/test/runner").runTestsFromModule(module);