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
123
124
125
126
|
/*
* Test that browser chrome UI interactions don't trigger a capture doorhanger.
*/
"use strict";
function* fillTestPage(aBrowser) {
yield ContentTask.spawn(aBrowser, null, function*() {
content.document.getElementById("form-basic-username").value = "my_username";
content.document.getElementById("form-basic-password").value = "my_password";
});
info("fields filled");
}
function* withTestPage(aTaskFn) {
return BrowserTestUtils.withNewTab({
gBrowser,
url: "https://example.com" + DIRECTORY_PATH + "formless_basic.html",
}, function*(aBrowser) {
info("tab opened");
yield fillTestPage(aBrowser);
yield* aTaskFn(aBrowser);
// Give a chance for the doorhanger to appear
yield new Promise(resolve => SimpleTest.executeSoon(resolve));
ok(!getCaptureDoorhanger("any"), "No doorhanger should be present");
});
}
add_task(function* setup() {
yield SimpleTest.promiseFocus(window);
});
add_task(function* test_urlbar_new_URL() {
yield withTestPage(function*(aBrowser) {
gURLBar.value = "";
let focusPromise = BrowserTestUtils.waitForEvent(gURLBar, "focus");
gURLBar.focus();
yield focusPromise;
info("focused");
EventUtils.sendString("http://mochi.test:8888/");
EventUtils.synthesizeKey("VK_RETURN", {});
yield BrowserTestUtils.browserLoaded(aBrowser, false, "http://mochi.test:8888/");
});
});
add_task(function* test_urlbar_fragment_enter() {
yield withTestPage(function*(aBrowser) {
gURLBar.focus();
EventUtils.synthesizeKey("VK_RIGHT", {});
EventUtils.sendString("#fragment");
EventUtils.synthesizeKey("VK_RETURN", {});
});
});
add_task(function* test_backButton_forwardButton() {
yield withTestPage(function*(aBrowser) {
// Load a new page in the tab so we can test going back
aBrowser.loadURI("https://example.com" + DIRECTORY_PATH + "formless_basic.html?second");
yield BrowserTestUtils.browserLoaded(aBrowser, false,
"https://example.com" + DIRECTORY_PATH +
"formless_basic.html?second");
yield fillTestPage(aBrowser);
let forwardButton = document.getElementById("forward-button");
// We need to wait for the forward button transition to complete before we
// can click it, so we hook up a listener to wait for it to be ready.
let forwardTransitionPromise = BrowserTestUtils.waitForEvent(forwardButton, "transitionend");
let backPromise = BrowserTestUtils.browserStopped(aBrowser);
EventUtils.synthesizeMouseAtCenter(document.getElementById("back-button"), {});
yield backPromise;
// Give a chance for the doorhanger to appear
yield new Promise(resolve => SimpleTest.executeSoon(resolve));
ok(!getCaptureDoorhanger("any"), "No doorhanger should be present");
// Now go forward again after filling
yield fillTestPage(aBrowser);
yield forwardTransitionPromise;
info("transition done");
yield BrowserTestUtils.waitForCondition(() => {
return forwardButton.disabled == false;
});
let forwardPromise = BrowserTestUtils.browserStopped(aBrowser);
info("click the forward button");
EventUtils.synthesizeMouseAtCenter(forwardButton, {});
yield forwardPromise;
});
});
add_task(function* test_reloadButton() {
yield withTestPage(function*(aBrowser) {
let reloadButton = document.getElementById("urlbar-reload-button");
let loadPromise = BrowserTestUtils.browserLoaded(aBrowser, false,
"https://example.com" + DIRECTORY_PATH +
"formless_basic.html");
yield BrowserTestUtils.waitForCondition(() => {
return reloadButton.disabled == false;
});
EventUtils.synthesizeMouseAtCenter(reloadButton, {});
yield loadPromise;
});
});
add_task(function* test_back_keyboard_shortcut() {
if (Services.prefs.getIntPref("browser.backspace_action") != 0) {
ok(true, "Skipped testing backspace to go back since it's disabled");
return;
}
yield withTestPage(function*(aBrowser) {
// Load a new page in the tab so we can test going back
aBrowser.loadURI("https://example.com" + DIRECTORY_PATH + "formless_basic.html?second");
yield BrowserTestUtils.browserLoaded(aBrowser, false,
"https://example.com" + DIRECTORY_PATH +
"formless_basic.html?second");
yield fillTestPage(aBrowser);
let backPromise = BrowserTestUtils.browserStopped(aBrowser);
EventUtils.synthesizeKey("VK_BACK_SPACE", {});
yield backPromise;
});
});
|