diff --git a/dom/base/test/bug704320.sjs b/dom/base/test/bug704320.sjs new file mode 100644 index 000000000000..0a41ca9a4732 --- /dev/null +++ b/dom/base/test/bug704320.sjs @@ -0,0 +1,246 @@ +var BASE_URL = 'example.com/tests/dom/base/test/bug704320.sjs'; + +function createTestUrl(schemeFrom, schemeTo, policy, action, type) { + return schemeTo + '://' + BASE_URL + '?' + + 'action=' + action + '&' + + 'scheme=' + schemeFrom + '-to-' + schemeTo + '&' + + 'policy=' + policy + '&' + + 'type=' + type; +} + +function create2ndLevelIframeUrl(schemeFrom, schemeTo, policy, type) { + return schemeFrom + '://' + BASE_URL + '?' + + 'action=create-2nd-level-iframe&' + + 'scheme-from=' + schemeFrom + '&' + + 'scheme-to=' + schemeTo + '&' + + 'policy=' + policy + '&' + + 'type=' + type; +} + +// Creates the following test cases for the specified scheme and referrer +// policy combination: +// +// @import +// font-face +// bg-url +// \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + '; +} + +function createIframedFormTest(schemeFrom, schemeTo, policy) { + var actionUrl = schemeTo + '://' + BASE_URL; + + return '\n\ + \n\ + \n\ + \n\ + \n\ + \n\ +
\n\ + \n\ + \n\ + \n\ + \n\ +
\n\ + \n\ + \n\ + '; +} + +function createIframedWindowLocationTest(schemeFrom, schemeTo, policy) { + var url = createTestUrl( + schemeFrom, schemeTo, policy, 'test', 'window.location'); + + return '\n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + '; +} + +function handleRequest(request, response) { + var sharedKey = 'bug704320.sjs'; + var params = request.queryString.split('&'); + var action = params[0].split('=')[1]; + + if (action === 'create-1st-level-iframe') { + // ?action=create-1st-level-iframe&scheme-from=http&scheme-to=https&policy=origin + var schemeFrom = params[1].split('=')[1]; + var schemeTo = params[2].split('=')[1]; + var policy = params[3].split('=')[1]; + + response.setHeader('Content-Type', 'text/html; charset=utf-8', false); + response.setHeader('Cache-Control', 'no-cache', false); + response.write(createTest(schemeFrom, schemeTo, policy)); + } + else if (action === 'create-2nd-level-iframe') { + // ?action=create-2nd-level-iframe&scheme-from=http&scheme-to=https&policy=origin&type=form" + var schemeFrom = params[1].split('=')[1]; + var schemeTo = params[2].split('=')[1]; + var policy = params[3].split('=')[1]; + var type = params[4].split('=')[1]; + + response.setHeader('Content-Type', 'text/html; charset=utf-8', false); + response.setHeader('Cache-Control', 'no-cache', false); + + if (type === 'form') { + response.write(createIframedFormTest(schemeFrom, schemeTo, policy)); + } else if (type === 'window.location') { + response.write(createIframedWindowLocationTest( + schemeFrom, schemeTo, policy)); + } + } + else if (action === 'test') { + // ?action=test&scheme=http-to-https&policy=origin&type=img + var scheme = params[1].split('=')[1]; + var policy = params[2].split('=')[1]; + var type = params[3].split('=')[1]; + var result = getSharedState(sharedKey); + + if (result === '') { + result = {}; + } else { + result = JSON.parse(result); + } + + if (!result[type]) { + result[type] = {}; + } + + if (!result[type][scheme]) { + result[type][scheme] = {}; + } + + if (request.hasHeader('Referer')) { + result[type][scheme][policy] = request.getHeader('Referer'); + } else { + result[type][scheme][policy] = ''; + } + + setSharedState(sharedKey, JSON.stringify(result)); + + if (type === 'link') { + var loc = 'https://example.com/tests/dom/base/test/file_bug704320_redirect.html'; + response.setStatusLine('1.1', 302, 'Found'); + response.setHeader('Location', loc, false); + } + + if (type === 'window.open') { + response.setHeader('Cache-Control', 'no-cache', false); + response.setHeader('Content-Type', 'text/html', false); + response.write(''); + } + } + else if (action === 'get-test-results') { + // ?action=get-result + response.setHeader('Cache-Control', 'no-cache', false); + response.setHeader('Content-Type', 'text/plain', false); + response.write(getSharedState(sharedKey)); + } +} diff --git a/dom/base/test/file_bug704320_redirect.html b/dom/base/test/file_bug704320_redirect.html new file mode 100644 index 000000000000..09ed05d6fddc --- /dev/null +++ b/dom/base/test/file_bug704320_redirect.html @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini index 38225ebd991c..cf86bc0cd23d 100644 --- a/dom/base/test/mochitest.ini +++ b/dom/base/test/mochitest.ini @@ -52,6 +52,7 @@ support-files = bug696301-script-1.js bug696301-script-1.js^headers^ bug696301-script-2.js + bug704320.sjs bug819051.sjs copypaste.js delayedServerEvents.sjs @@ -138,6 +139,7 @@ support-files = file_bug687859-http.js^headers^ file_bug687859-inherit.js file_bug692434.xml + file_bug704320_redirect.html file_bug707142_baseline.json file_bug707142_bom.json file_bug707142_utf-16.json @@ -593,6 +595,8 @@ skip-if = buildapp == 'b2g' [test_bug698381.html] [test_bug698384.html] [test_bug704063.html] +[test_bug704320.html] +skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # b2g (Needs multiple window.open support) android(times out, bug 1100609) e10s(randomly fails, bug 1100362) [test_bug707142.html] [test_bug708620.html] [test_bug711047.html] diff --git a/dom/base/test/test_bug704320.html b/dom/base/test/test_bug704320.html new file mode 100644 index 000000000000..5faa9e420eb4 --- /dev/null +++ b/dom/base/test/test_bug704320.html @@ -0,0 +1,232 @@ + + + + + + Test for Bug 704320 + + + + +Mozilla Bug 704320 +

+
+
+
+
+ + + + +