From 9ba2ab5ceaab60b48a8eb830601abf2cef05ecea Mon Sep 17 00:00:00 2001 From: Marc Laval Date: Thu, 20 Aug 2015 10:02:42 +0200 Subject: [PATCH] chore(build): add IE11 to CI --- karma-js.conf.js | 4 +- .../angular2/src/test_lib/shims_for_IE.dart | 1 - modules/angular2/src/test_lib/shims_for_IE.js | 87 +++++++++++++++++++ modules/angular2/src/test_lib/shims_for_IE.ts | 13 --- sauce.conf.js | 2 +- 5 files changed, 90 insertions(+), 17 deletions(-) delete mode 100644 modules/angular2/src/test_lib/shims_for_IE.dart create mode 100644 modules/angular2/src/test_lib/shims_for_IE.js delete mode 100644 modules/angular2/src/test_lib/shims_for_IE.ts diff --git a/karma-js.conf.js b/karma-js.conf.js index f607206ba6..1bbed6cc0e 100644 --- a/karma-js.conf.js +++ b/karma-js.conf.js @@ -20,13 +20,13 @@ module.exports = function(config) { 'node_modules/traceur/bin/traceur-runtime.js', 'node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.src.js', // Including systemjs because it defines `__eval`, which produces correct stack traces. + 'modules/angular2/src/test_lib/shims_for_IE.js', 'node_modules/systemjs/dist/system.src.js', {pattern: 'node_modules/rx/dist/rx.js', included: false, watched: false, served: true}, 'node_modules/reflect-metadata/Reflect.js', 'tools/build/file2modulename.js', 'test-main.js', - {pattern: 'modules/**/test/**/static_assets/**', included: false, watched: false}, - 'modules/angular2/src/test_lib/shims_for_IE.ts' + {pattern: 'modules/**/test/**/static_assets/**', included: false, watched: false} ], exclude: [ diff --git a/modules/angular2/src/test_lib/shims_for_IE.dart b/modules/angular2/src/test_lib/shims_for_IE.dart deleted file mode 100644 index a70b4cf718..0000000000 --- a/modules/angular2/src/test_lib/shims_for_IE.dart +++ /dev/null @@ -1 +0,0 @@ -library angular2.test_lib.shims_for_ie; diff --git a/modules/angular2/src/test_lib/shims_for_IE.js b/modules/angular2/src/test_lib/shims_for_IE.js new file mode 100644 index 0000000000..9bb828bdb1 --- /dev/null +++ b/modules/angular2/src/test_lib/shims_for_IE.js @@ -0,0 +1,87 @@ +// function.name (all IE) +/*! @source http://stackoverflow.com/questions/6903762/function-name-not-supported-in-ie*/ +if (!Object.hasOwnProperty('name')) { + Object.defineProperty(Function.prototype, 'name', { + get: function() { + var name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]; + // For better performance only parse once, and then cache the + // result through a new accessor for repeated access. + Object.defineProperty(this, 'name', {value: name}); + return name; + } + }); +} + +// URL polyfill for SystemJS (all IE) +/*! @source https://github.com/ModuleLoader/es6-module-loader/blob/master/src/url-polyfill.js*/ +// from https://gist.github.com/Yaffle/1088850 +(function(global) { + function URLPolyfill(url, baseURL) { + if (typeof url != 'string') { + throw new TypeError('URL must be a string'); + } + var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/); + if (!m) { + throw new RangeError(); + } + var protocol = m[1] || ""; + var username = m[2] || ""; + var password = m[3] || ""; + var host = m[4] || ""; + var hostname = m[5] || ""; + var port = m[6] || ""; + var pathname = m[7] || ""; + var search = m[8] || ""; + var hash = m[9] || ""; + if (baseURL !== undefined) { + var base = baseURL instanceof URLPolyfill ? baseURL : new URLPolyfill(baseURL); + var flag = protocol === "" && host === "" && username === ""; + if (flag && pathname === "" && search === "") { + search = base.search; + } + if (flag && pathname.charAt(0) !== "/") { + pathname = (pathname !== "" ? (((base.host !== "" || base.username !== "") && base.pathname === "" ? "/" : "") + base.pathname.slice(0, base.pathname.lastIndexOf("/") + 1) + pathname) : base.pathname); + } + // dot segments removal + var output = []; + pathname.replace(/^(\.\.?(\/|$))+/, "") + .replace(/\/(\.(\/|$))+/g, "/") + .replace(/\/\.\.$/, "/../") + .replace(/\/?[^\/]*/g, function (p) { + if (p === "/..") { + output.pop(); + } else { + output.push(p); + } + }); + pathname = output.join("").replace(/^\//, pathname.charAt(0) === "/" ? "/" : ""); + if (flag) { + port = base.port; + hostname = base.hostname; + host = base.host; + password = base.password; + username = base.username; + } + if (protocol === "") { + protocol = base.protocol; + } + } + + // convert windows file URLs to use / + if (protocol == 'file:') + pathname = pathname.replace(/\\/g, '/'); + + this.origin = protocol + (protocol !== "" || host !== "" ? "//" : "") + host; + this.href = protocol + (protocol !== "" || host !== "" ? "//" : "") + (username !== "" ? username + (password !== "" ? ":" + password : "") + "@" : "") + host + pathname + search + hash; + this.protocol = protocol; + this.username = username; + this.password = password; + this.host = host; + this.hostname = hostname; + this.port = port; + this.pathname = pathname; + this.search = search; + this.hash = hash; + } +global.URLPolyfill = URLPolyfill; +})(typeof self != 'undefined' ? self : global); \ No newline at end of file diff --git a/modules/angular2/src/test_lib/shims_for_IE.ts b/modules/angular2/src/test_lib/shims_for_IE.ts deleted file mode 100644 index adb0720eca..0000000000 --- a/modules/angular2/src/test_lib/shims_for_IE.ts +++ /dev/null @@ -1,13 +0,0 @@ -// function.name -/*! @source http://stackoverflow.com/questions/6903762/function-name-not-supported-in-ie*/ -if (!Object.hasOwnProperty('name')) { - Object.defineProperty(Function.prototype, 'name', { - get: function() { - var name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]; - // For better performance only parse once, and then cache the - // result through a new accessor for repeated access. - Object.defineProperty(this, 'name', {value: name}); - return name; - } - }); -} diff --git a/sauce.conf.js b/sauce.conf.js index 7d7203d911..4dbb84d6b3 100644 --- a/sauce.conf.js +++ b/sauce.conf.js @@ -125,7 +125,7 @@ var aliases = { 'SAFARI': ['SL_SAFARI7', 'SL_SAFARI8'], 'BETA': ['SL_CHROMEBETA', 'SL_FIREFOXBETA'], 'DEV': ['SL_CHROMEDEV', 'SL_FIREFOXDEV'], - 'CI': ['SL_CHROME', 'SL_ANDROID5.1', 'SL_SAFARI8', 'SL_IOS8', 'SL_FIREFOX'] + 'CI': ['SL_CHROME', 'SL_ANDROID5.1', 'SL_SAFARI8', 'SL_IOS8', 'SL_FIREFOX', 'SL_IE11'] }; module.exports = {