summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_bug704320.html
blob: 5c8e46c03d37524ee3e4f6ba67ea6245f05ce8e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=704320
-->
<head>
  <meta charset="utf-8">
  <title>Test for Bug 704320</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="referrerHelper.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>

<script type="application/javascript;version=1.7">

//generates URLs to test
var generateURLArray = (function(from, to){
  const baseURL = '://example.com/tests/dom/base/test/bug704320.sjs?action=create-1st-level-iframe&scheme-from=';
  const schemeTo = '&scheme-to=';

  return [
    from + baseURL + from + schemeTo + to + '&policy=no-referrer-when-downgrade',
    from + baseURL + from + schemeTo + to + '&policy=no-referrer',
    from + baseURL + from + schemeTo + to + '&policy=unsafe-url',
    from + baseURL + from + schemeTo + to + '&policy=origin',
    from + baseURL + from + schemeTo + to + '&policy=origin-when-cross-origin',
    from + baseURL + from + schemeTo + to + '&policy=same-origin',
    from + baseURL + from + schemeTo + to + '&policy=strict-origin',
    from + baseURL + from + schemeTo + to + '&policy=strict-origin-when-cross-origin',
  ];
});

var testIframeUrls = generateURLArray('http', 'http');
testIframeUrls = testIframeUrls.concat(generateURLArray('https', 'https'));
testIframeUrls = testIframeUrls.concat(generateURLArray('http', 'https'));
testIframeUrls = testIframeUrls.concat(generateURLArray('https', 'http'));

SimpleTest.waitForExplicitFinish();
var advance = function() { tests.next(); };

/**
 * This is the main test routine -- serialized by use of a generator.
 * It performs all tests in sequence using in the same iframe.
 */
var tests = (function() {
  SimpleTest.requestLongerTimeout(4);
  var iframe = document.getElementById("testframe");
  iframe.onload = function() {
     advance();
  }

  // load the test frame from testIframeUrls[url]
  // it will call back into this function via postMessage when it finishes loading.
  // and continue beyond the yield.
  for(url in testIframeUrls) {
    yield iframe.src = testIframeUrls[url];
    // run test and check result for loaded test URL
    yield checkExpectedGlobalResults();
  }

  // complete.  Be sure to yield so we don't call this twice.
  yield SimpleTest.finish();
})();

</script>
</head>

<body onload="tests.next();">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=704320">Mozilla Bug 704320 - HTTP/HTTPS to HTTPS/HTTP</a>
<p id="display"></p>
<pre id="content">
</pre>
  <iframe id="testframe"></iframe>

</body>