summaryrefslogtreecommitdiffstats
path: root/dom/security/test/csp/file_image_nonce.html
blob: 5d57bb8372923fd4a3feadc7aa30fe1c35ba6884 (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
<!DOCTYPE HTML>
<html>
  <head>
  <meta charset='utf-8'>
  <title>Bug 1355801: Nonce should not apply to images</title>
  </head>
<body>

<img id='matchingNonce' src='http://mochi.test:8888/tests/image/test/mochitest/blue.png?a' nonce='abc'></img>
<img id='nonMatchingNonce' src='http://mochi.test:8888/tests/image/test/mochitest/blue.png?b' nonce='bca'></img>
<img id='noNonce' src='http://mochi.test:8888/tests/image/test/mochitest/blue.png?c'></img>

<script type='application/javascript'>
  var matchingNonce = document.getElementById('matchingNonce');
  matchingNonce.onload = function(e) {
    window.parent.postMessage({result: 'img-with-matching-nonce-loaded'}, '*');
  };
  matchingNonce.onerror = function(e) {
    window.parent.postMessage({result: 'img-with-matching-nonce-blocked'}, '*');
  }

  var nonMatchingNonce = document.getElementById('nonMatchingNonce');
  nonMatchingNonce.onload = function(e) {
    window.parent.postMessage({result: 'img-with_non-matching-nonce-loaded'}, '*');
  };
  nonMatchingNonce.onerror = function(e) {
    window.parent.postMessage({result: 'img-with_non-matching-nonce-blocked'}, '*');
  }

  var noNonce = document.getElementById('noNonce');
  noNonce.onload = function(e) {
    window.parent.postMessage({result: 'img-without-nonce-loaded'}, '*');
  };
  noNonce.onerror = function(e) {
    window.parent.postMessage({result: 'img-without-nonce-blocked'}, '*');
  }
</script>
</body>
</html>