Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test("listeners are invoked on load", function() {
stop();
expect(1);
oasis.on('xhr.load', function () {
start();
ok(true, 'load listener was called');
});
oasis.xhr('/fixtures/index.js')['catch'](RSVP.rethrow);
});
test("listeners are invoked on send", function() {
expect(1);
stop(2);
oasis.on('xhr.send', function () {
start();
ok(true, 'send listener was called');
});
oasis.xhr('/fixtures/index.js').then(function () {
start();
})['catch'](RSVP.rethrow);
});
fetchResource: function (url, oasis) {
var adapter = this;
return xhr(url, {
dataType: 'text'
}, oasis).then(function (code) {
return adapter.wrapResource(code);
})['catch'](RSVP.rethrow);
},
connectPorts: function () {
var sandbox = this;
var allSandboxPortPromises = a_reduce.call(this._capabilitiesToConnect, function (accumulator, capability) {
return accumulator.concat(sandbox.sandboxPortDefereds[capability].promise);
}, []);
RSVP.all(allSandboxPortPromises).then(function (ports) {
Logger.log("container: All " + ports.length + " ports created. Transferring them.");
sandbox.adapter.connectPorts(sandbox, ports);
})['catch'](RSVP.rethrow);
},
didConnect: function(oasis) {
var adapter = this;
return oasis.sandbox._waitForLoadDeferred().resolve(loadSandboxJS()['catch'](RSVP.rethrow));
function applySandboxJS(sandboxFn) {
Logger.log("sandbox: inline sandbox initialized");
sandboxFn(oasis);
return oasis.sandbox;
}
function loadSandboxJS() {
return new RSVP.Promise(function (resolve, reject) {
resolve(adapter.fetchResource(oasis.sandbox.options.url, oasis).
then(applySandboxJS));
});
}
},
});
export function registerHandler(oasis, capability, options) {
var port = oasis.ports[capability];
if (port) {
Logger.log(oasis.oasisId, "sandbox: found port, setting up '" + capability + "'");
options.setupCapability(port);
if (options.promise) {
options.promise.then(function() {
port.start();
})['catch'](RSVP.rethrow);
} else {
port.start();
}
} else if (!oasis.receivedPorts) {
Logger.log("No port found, saving handler for '" + capability + "'");
oasis.handlers[capability] = options;
} else {
Logger.log("No port was sent for capability '" + capability + "'");
options.rejectCapability();
}
}