4 https://bugzilla.mozilla.org/show_bug.cgi?id=1197901
8 <title>Test for Bug
1197901</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
11 <script type=
"application/javascript">
13 /** Test for Bug
1197901 **/
14 SimpleTest.requestFlakyTimeout(
"requestFlakyTimeout is silly");
15 SimpleTest.waitForExplicitFinish();
16 window.onload = function() {
17 SimpleTest.waitForFocus(function() {
18 SpecialPowers.pushPrefEnv({
"set": [[
"device.sensors.test.events", true]]},
24 window.onmessage = function(event) {
25 ok(event.data.result, event.data.message);
28 // Only same-origin iframe should get the events.
29 var xo = document.getElementById(
"cross-origin");
30 xo.contentWindow.postMessage(
31 { command:
"addEventListener",
33 message:
"Cross-origin iframe shouldn't get the sensor events."},
36 var so = document.getElementById(
"same-origin");
37 so.contentWindow.postMessage(
38 { command:
"addEventListener",
40 message:
"Same-origin iframe should get the sensor events." },
43 // We need a timeout here to check that something does not happen.
44 setTimeout(function() {
51 function doWindowTest() {
52 var win = window.open(
"file_bug1197901.html",
"w1",
"height=100,width=100");
53 win.onload = function() {
55 SimpleTest.waitForFocus(function() {
56 var win2 = window.open(
"file_bug1197901.html",
"w2",
"height=100,width=100,left=100");
57 win2.onload = function() {
59 SimpleTest.waitForFocus(function() {
60 // Only focused window should get the events.
62 { command:
"addEventListener",
64 message:
"Only focused window should get the sensor events." },
67 { command:
"addEventListener",
69 message:
"Focused window should get the sensor events." },
71 setTimeout(function() {
72 window.onmessage = null;
86 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug
</a>
88 <div id=
"content" style=
"display: none">
93 <iframe src=
"file_bug1197901.html" id=
"same-origin"></iframe>
94 <iframe src=
"http://example.com/tests/dom/system/tests/file_bug1197901.html" id=
"cross-origin"></iframe>