summaryrefslogtreecommitdiffstats
path: root/dom/security/test/general/test_bug1450853.html
blob: e6b61ecce010892c8abce47ed4257fbc14e4e21f (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1450853
-->
<head>
<meta charset="utf-8">
<title>Test for Cross-origin resouce status leak via MediaError</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/ChromeTask.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>

<audio autoplay id="audio"></audio>

<script type="application/javascript">

/** Test for Bug 1450853 **/
var CONST_GENERIC_ERROR_MESSAGE = "Failed to open media";

add_task(function() {
  return new Promise((resolve) => {
      let audioElement = document.getElementById("audio");

      audioElement.onerror = function() {
      let err = this.error;
      let message = err.message;

      info(`Got Audio Error -> ${message}`);
      ok(message.includes("404"), "Same-Origin Error Message should contain status data");
      resolve();
    };
  audioElement.src = "http://mochi.test:8888/media/test.mp3";
  });
});

add_task(function() {
  return new Promise((resolve) => {
      let audioElement = document.getElementById("audio");

      audioElement.onerror = function() {
      let err = this.error;
      let message = err.message;

      info(`Got Audio Error -> ${message}`);
      is(message, CONST_GENERIC_ERROR_MESSAGE, "Cross-Origin Same-Site Error Message should be generic");
      resolve();
    };
  audioElement.src = "http://mochi.test:9999/media/test.mp3";
  });
});

add_task(function() {
  return new Promise((resolve) => {
      let audioElement = document.getElementById("audio");

      audioElement.onerror = function() {
      let err = this.error;
      let message = err.message;

      info(`Got Audio Error -> ${message}`);
      is(message, CONST_GENERIC_ERROR_MESSAGE, "Cross-Origin Same-Site Error Message should be generic");
      resolve();
    };
  audioElement.src = "http://sub.mochi.test:8888/media/test.mp3";
  });
});

add_task(function() {
  return new Promise((resolve) => {
      let audioElement = document.getElementById("audio");

      audioElement.onerror = function() {
      let err = this.error;
      let message = err.message;

      info(`Got Audio Error -> ${message}`);
      is(message, CONST_GENERIC_ERROR_MESSAGE, "Cross-Origin Error Message should be generic");
      resolve();
    };
  audioElement.src = "https://example.com/media/test.mp3";
  });
});

</script>
</head>

<body>
    <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1450853">Mozilla Bug 1450853</a>
    <iframe width="0" height="0"></iframe>
  </body>
</html>