blob: 25317b9fc83c949c1b9e61b412cadc9512190e43 (
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
|
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1058311 - controlled page</title>
<script class="testbody" type="text/javascript">
var re = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
var frameType = "none";
var testWindow = parent;
if (parent != window) {
frameType = "nested";
} else if (opener) {
frameType = "auxiliary";
testWindow = opener;
} else if (parent != window) {
frameType = "top-level";
} else {
postResult(false, "Unexpected frameType");
}
window.onload = function() {
navigator.serviceWorker.ready.then(function(swr) {
swr.active.postMessage("Start");
});
}
function postResult(result, msg) {
response = {
result: result,
message: msg
};
testWindow.postMessage(response, "*");
}
navigator.serviceWorker.onmessage = function(msg) {
// worker message;
result = re.test(msg.data.id);
postResult(result, "Client id test");
result = msg.data.url == window.location;
postResult(result, "Client url test");
result = msg.data.visibilityState === document.visibilityState;
postResult(result, "Client visibility test. expected=" +document.visibilityState);
result = msg.data.focused === document.hasFocus();
postResult(result, "Client focus test. expected=" + document.hasFocus());
result = msg.data.frameType === frameType;
postResult(result, "Client frameType test. expected=" + frameType);
postResult(true, "DONE");
window.close();
};
</script>
</head>
<body>
</body>
</html>
|