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
|
// Utilities to help talk between the frame_ iframe documents and the parent
// tests.
var _parentOrigin = "https://example.com/";
function local_setParentOrigin(aOrigin) {
_parentOrigin = aOrigin;
}
function handleEventMessage(event) {
if ("test" in event.data) {
let summary = event.data.test + ": " + event.data.msg;
ok(event.data.status, summary);
} else if ("done" in event.data) {
SimpleTest.finish();
} else {
ok(false, "Unexpected message in the test harness: " + event.data);
}
}
function local_is(value, expected, message) {
if (value === expected) {
local_ok(true, message);
} else {
local_ok(false, message + " unexpectedly: " + value + " !== " + expected);
}
}
function local_isnot(value, expected, message) {
if (value !== expected) {
local_ok(true, message);
} else {
local_ok(false, message + " unexpectedly: " + value + " === " + expected);
}
}
function local_ok(expression, message) {
let body = { test: this.location.pathname, status: expression, msg: message };
parent.postMessage(body, _parentOrigin);
}
function local_doesThrow(fn, name) {
let gotException = false;
try {
fn();
} catch (ex) {
gotException = true;
}
local_ok(gotException, name);
}
function local_finished() {
parent.postMessage({ done: true }, _parentOrigin);
}
|