Merge remote-tracking branch 'remotes/pull/1866'

This commit is contained in:
nightwing 2014-03-23 15:20:15 +04:00
commit d76e3e29c6
2 changed files with 14 additions and 1 deletions

View file

@ -38,4 +38,14 @@ exports.loadScript = function(path, callback) {
};
};
/*
* Convert a url into a fully qualified absolute URL
* This function does not work in IE6
*/
exports.qualifyURL = function(url) {
var a = document.createElement('a');
a.href = url;
return a.href;
}
});

View file

@ -32,6 +32,7 @@ define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var net = require("../lib/net");
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var config = require("../config");
@ -179,7 +180,9 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
};
this.$workerBlob = function(workerUrl) {
var script = "importScripts('" + workerUrl + "');";
// workerUrl can be protocol relative
// importScripts only takes fully qualified urls
var script = "importScripts('" + net.qualifyURL( workerUrl ) + "');";
try {
return new Blob([script], {"type": "application/javascript"});
} catch (e) { // Backwards-compatibility