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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
function busyChecker(isBusy) {
return function (event) {
let scEvent;
try {
scEvent = event.QueryInterface(nsIAccessibleStateChangeEvent);
} catch (e) {
return false;
}
return scEvent.state == STATE_BUSY && scEvent.isEnabled == isBusy;
};
}
function inIframeChecker(iframeId) {
return function (event) {
return getAccessibleDOMNodeID(event.accessibleDocument.parent) == iframeId;
};
}
function urlChecker(url) {
return function (event) {
info(`${event.accessibleDocument.URL} == ${url}`);
return event.accessibleDocument.URL == url;
};
}
async function runTests(browser, accDoc) {
let onLoadEvents = waitForEvents({
expected: [
[EVENT_REORDER, getAccessible(browser)],
[EVENT_DOCUMENT_LOAD_COMPLETE, "body2"],
[EVENT_STATE_CHANGE, busyChecker(false)],
],
unexpected: [
[EVENT_DOCUMENT_LOAD_COMPLETE, inIframeChecker("iframe1")],
[EVENT_STATE_CHANGE, inIframeChecker("iframe1")],
],
});
BrowserTestUtils.loadURIString(
browser,
`data:text/html;charset=utf-8,
<html><body id="body2">
<iframe id="iframe1" src="http://example.com"></iframe>
</body></html>`
);
await onLoadEvents;
onLoadEvents = waitForEvents([
[EVENT_DOCUMENT_LOAD_COMPLETE, urlChecker("about:about")],
[EVENT_STATE_CHANGE, busyChecker(false)],
[EVENT_REORDER, getAccessible(browser)],
]);
BrowserTestUtils.loadURIString(browser, "about:about");
await onLoadEvents;
onLoadEvents = waitForEvents([
[EVENT_DOCUMENT_RELOAD, evt => evt.isFromUserInput],
[EVENT_REORDER, getAccessible(browser)],
[EVENT_STATE_CHANGE, busyChecker(false)],
]);
EventUtils.synthesizeKey("VK_F5", {}, browser.ownerGlobal);
await onLoadEvents;
onLoadEvents = waitForEvents([
[EVENT_DOCUMENT_LOAD_COMPLETE, urlChecker("about:mozilla")],
[EVENT_STATE_CHANGE, busyChecker(false)],
[EVENT_REORDER, getAccessible(browser)],
]);
BrowserTestUtils.loadURIString(browser, "about:mozilla");
await onLoadEvents;
onLoadEvents = waitForEvents([
[EVENT_DOCUMENT_RELOAD, evt => !evt.isFromUserInput],
[EVENT_REORDER, getAccessible(browser)],
[EVENT_STATE_CHANGE, busyChecker(false)],
]);
browser.reload();
await onLoadEvents;
onLoadEvents = waitForEvents([
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
[EVENT_DOCUMENT_LOAD_COMPLETE, urlChecker("http://www.wronguri.wronguri/")],
[EVENT_STATE_CHANGE, busyChecker(false)],
[EVENT_REORDER, getAccessible(browser)],
]);
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
BrowserTestUtils.loadURIString(browser, "http://www.wronguri.wronguri/");
await onLoadEvents;
onLoadEvents = waitForEvents([
[EVENT_DOCUMENT_LOAD_COMPLETE, urlChecker("https://nocert.example.com/")],
[EVENT_STATE_CHANGE, busyChecker(false)],
[EVENT_REORDER, getAccessible(browser)],
]);
BrowserTestUtils.loadURIString(browser, "https://nocert.example.com:443/");
await onLoadEvents;
}
/**
* Test caching of accessible object states
*/
addAccessibleTask("", runTests);
|