diff --git a/lib/middleware/karma.js b/lib/middleware/karma.js index ec4c26184..fbd8956c4 100644 --- a/lib/middleware/karma.js +++ b/lib/middleware/karma.js @@ -13,6 +13,7 @@ var path = require('path'); var util = require('util'); +var urlparse = require('url').parse; var common = require('./common'); @@ -25,7 +26,6 @@ var SCRIPT_TYPE = { '.dart': 'application/dart' }; - var filePathToUrlPath = function(filePath, basePath) { if (filePath.indexOf(basePath) === 0) { return '/base' + filePath.substr(basePath.length); @@ -34,6 +34,25 @@ var filePathToUrlPath = function(filePath, basePath) { return '/absolute' + filePath; }; +var getXUACompatibleMetaElement = function(url) { + var tag = ''; + var urlObj = urlparse(url, true); + if (urlObj.query['x-ua-compatible']) { + tag = '\n'; + } + return tag; +}; + +var getXUACompatibleUrl = function(url) { + var value = ''; + var urlObj = urlparse(url, true); + if (urlObj.query['x-ua-compatible']) { + value = '?x-ua-compatible=' + encodeURIComponent(urlObj.query['x-ua-compatible']); + } + return value; +}; + var createKarmaMiddleware = function(filesPromise, serveStaticFile, /* config.basePath */ basePath, /* config.urlRoot */ urlRoot) { @@ -57,7 +76,11 @@ var createKarmaMiddleware = function(filesPromise, serveStaticFile, // serve client.html if (requestUrl === '/') { - return serveStaticFile('/client.html', response); + return serveStaticFile('/client.html', response, function(data) { + return data + .replace('\n%X_UA_COMPATIBLE%', getXUACompatibleMetaElement(request.url)) + .replace('%X_UA_COMPATIBLE_URL%', getXUACompatibleUrl(request.url)); + }); } // serve karma.js @@ -109,7 +132,10 @@ var createKarmaMiddleware = function(filesPromise, serveStaticFile, mappings = 'window.__karma__.files = {\n' + mappings.join(',\n') + '\n};\n'; - return data.replace('%SCRIPTS%', scriptTags.join('\n')).replace('%MAPPINGS%', mappings); + return data. + replace('%SCRIPTS%', scriptTags.join('\n')) + .replace('%MAPPINGS%', mappings) + .replace('\n%X_UA_COMPATIBLE%', getXUACompatibleMetaElement(request.url)); }); }, function(errorFiles) { serveStaticFile(requestUrl, response, function(data) { diff --git a/static/client.html b/static/client.html index 5a139223f..72f8dce13 100644 --- a/static/client.html +++ b/static/client.html @@ -5,6 +5,7 @@ -->
+%X_UA_COMPATIBLE%