summaryrefslogtreecommitdiffstats
path: root/dom/presentation/tests/mochitest/file_presentation_receiver_auxiliary_navigation.html
blob: 3a60603101bc5da939422ff19ed30e6ce65aa0b9 (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
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test for sandboxed auxiliary navigation flag in receiver page</title>
</head>
<body>
<div id="content"></div>
<script type="application/javascript;version=1.7">

"use strict";

function is(a, b, msg) {
  alert((a === b ? 'OK ' : 'KO ') + msg);
}

function ok(a, msg) {
  alert((a ? 'OK ' : 'KO ') + msg);
}

function info(msg) {
  alert('INFO ' + msg);
}

function command(msg) {
  alert('COMMAND ' + JSON.stringify(msg));
}

function finish() {
  alert('DONE');
}

function testConnectionAvailable() {
  return new Promise(function(aResolve, aReject) {
    ok(navigator.presentation, "navigator.presentation should be available in OOP receiving pages.");
    ok(navigator.presentation.receiver, "navigator.presentation.receiver should be available in receiving pages.");

    aResolve();
  });
}

function testOpenWindow() {
  return new Promise(function(aResolve, aReject) {
    try {
      window.open("http://example.com");
      ok(false, "receiver page should not be able to open a new window.");
    } catch(e) {
      ok(true, "receiver page should not be able to open a new window.");
      aResolve();
    }
  });
}

testConnectionAvailable().
then(testOpenWindow).
then(finish);

</script>
</body>
</html>