зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset a72a5e849a5d (bug 1840827) for causing failures at browser_windowopen.js. CLOSED TREE
This commit is contained in:
Родитель
2b36fbf1bb
Коммит
fd1f07a969
|
@ -467,7 +467,7 @@ export class UrlbarInput {
|
|||
|
||||
this.value = value;
|
||||
this.valueIsTyped = !valid;
|
||||
this.toggleAttribute("usertyping", !valid);
|
||||
this.removeAttribute("usertyping");
|
||||
|
||||
if (this.focused && value != previousUntrimmedValue) {
|
||||
if (
|
||||
|
@ -3475,7 +3475,11 @@ export class UrlbarInput {
|
|||
this._compositionClosedPopup = false;
|
||||
}
|
||||
|
||||
this.toggleAttribute("usertyping", !!value);
|
||||
if (value) {
|
||||
this.setAttribute("usertyping", "true");
|
||||
} else {
|
||||
this.removeAttribute("usertyping");
|
||||
}
|
||||
this.removeAttribute("actiontype");
|
||||
|
||||
if (
|
||||
|
@ -3653,7 +3657,11 @@ export class UrlbarInput {
|
|||
this._setValue(value);
|
||||
this.window.gBrowser.userTypedValue = value;
|
||||
|
||||
this.toggleAttribute("usertyping", !!this._untrimmedValue);
|
||||
if (this._untrimmedValue) {
|
||||
this.setAttribute("usertyping", "true");
|
||||
} else {
|
||||
this.removeAttribute("usertyping");
|
||||
}
|
||||
|
||||
// Fix up cursor/selection:
|
||||
let newCursorPos = oldStart.length + pasteData.length;
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
/**
|
||||
* This test is designed to ensure that the correct command/operation happens
|
||||
* when pressing Enter, or clicking the Go button, with various key
|
||||
* combinations in the urlbar.
|
||||
* when pressing enter with various key combinations in the urlbar.
|
||||
*/
|
||||
|
||||
const TEST_VALUE = "example.com";
|
||||
|
@ -32,7 +31,7 @@ add_task(async function alt_left_click_test() {
|
|||
};
|
||||
});
|
||||
|
||||
await typeAndCommand("click", { altKey: true });
|
||||
await triggerCommand("click", { altKey: true });
|
||||
|
||||
await saveURLPromise;
|
||||
ok(true, "SaveURL was called");
|
||||
|
@ -46,7 +45,7 @@ add_task(async function shift_left_click_test() {
|
|||
let newWindowPromise = BrowserTestUtils.waitForNewWindow({
|
||||
url: destinationURL,
|
||||
});
|
||||
await typeAndCommand("click", { shiftKey: true });
|
||||
await triggerCommand("click", { shiftKey: true });
|
||||
let win = await newWindowPromise;
|
||||
|
||||
info("URL should be loaded in a new window");
|
||||
|
@ -74,7 +73,7 @@ add_task(async function right_click_test() {
|
|||
// Add a new tab.
|
||||
await promiseOpenNewTab();
|
||||
|
||||
await typeAndCommand("click", { button: 2 });
|
||||
await triggerCommand("click", { button: 2 });
|
||||
|
||||
// Right click should do nothing (context menu will be shown).
|
||||
is(gURLBar.value, TEST_VALUE, "Urlbar still has the value we entered");
|
||||
|
@ -90,7 +89,7 @@ add_task(async function shift_accel_left_click_test() {
|
|||
let tab = await promiseOpenNewTab();
|
||||
|
||||
let loadStartedPromise = promiseLoadStarted();
|
||||
await typeAndCommand("click", { accelKey: true, shiftKey: true });
|
||||
await triggerCommand("click", { accelKey: true, shiftKey: true });
|
||||
await loadStartedPromise;
|
||||
|
||||
// Check the load occurred in a new background tab.
|
||||
|
@ -143,7 +142,7 @@ add_task(async function load_in_current_tab_test() {
|
|||
|
||||
// Trigger a load and check it occurs in the current tab.
|
||||
let loadStartedPromise = promiseLoadStarted();
|
||||
await typeAndCommand(type, details);
|
||||
await triggerCommand(type, details);
|
||||
await loadStartedPromise;
|
||||
|
||||
info("URL should be loaded in the current tab");
|
||||
|
@ -191,7 +190,7 @@ add_task(async function load_in_new_tab_test() {
|
|||
|
||||
// Trigger a load and check it occurs in a new tab.
|
||||
let tabSwitchedPromise = promiseNewTabSwitched();
|
||||
await typeAndCommand(type, details);
|
||||
await triggerCommand(type, details);
|
||||
await tabSwitchedPromise;
|
||||
|
||||
// Check the load occurred in a new tab.
|
||||
|
@ -211,68 +210,27 @@ add_task(async function load_in_new_tab_test() {
|
|||
}
|
||||
});
|
||||
|
||||
add_task(async function go_button_after_tab_switch() {
|
||||
// Add a new tab.
|
||||
let tab = await promiseOpenNewTab();
|
||||
async function triggerCommand(type, details = {}) {
|
||||
gURLBar.focus();
|
||||
gURLBar.value = "";
|
||||
EventUtils.sendString(TEST_VALUE);
|
||||
|
||||
await UrlbarTestUtils.inputIntoURLBar(window, TEST_VALUE);
|
||||
await BrowserTestUtils.switchTab(gBrowser, gBrowser.visibleTabs[0]);
|
||||
isnot(
|
||||
gURLBar.value,
|
||||
TEST_VALUE,
|
||||
"Urlbar does not have the entered value after switching to a different tab"
|
||||
);
|
||||
await BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
is(
|
||||
gURLBar.value,
|
||||
TEST_VALUE,
|
||||
"Urlbar still has the entered value restored after switching back to the new tab"
|
||||
);
|
||||
|
||||
// Trigger a load and check it occurs in the current tab.
|
||||
let loadStartedPromise = promiseLoadStarted();
|
||||
await triggerCommand("click");
|
||||
await loadStartedPromise;
|
||||
|
||||
info("URL should be loaded in the current tab");
|
||||
is(gURLBar.value, TEST_VALUE, "Urlbar still has the value we entered");
|
||||
await promiseCheckChildNoFocusedElement(gBrowser.selectedBrowser);
|
||||
is(
|
||||
document.activeElement,
|
||||
gBrowser.selectedBrowser,
|
||||
"Content window should be focused"
|
||||
);
|
||||
is(gBrowser.selectedTab, tab, "New URL was loaded in the current tab");
|
||||
|
||||
// Cleanup.
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
async function typeAndCommand(eventType, details = {}) {
|
||||
await UrlbarTestUtils.inputIntoURLBar(window, TEST_VALUE);
|
||||
await triggerCommand(eventType, details);
|
||||
}
|
||||
|
||||
async function triggerCommand(eventType, details = {}) {
|
||||
Assert.equal(
|
||||
await UrlbarTestUtils.promiseUserContextId(window),
|
||||
gBrowser.selectedTab.getAttribute("usercontextid"),
|
||||
"userContextId must be the same as the originating tab"
|
||||
);
|
||||
|
||||
switch (eventType) {
|
||||
case "click":
|
||||
ok(
|
||||
gURLBar.hasAttribute("usertyping"),
|
||||
"usertyping attribute must be set for the go button to be visible"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(gURLBar.goButton, details);
|
||||
break;
|
||||
case "keypress":
|
||||
EventUtils.synthesizeKey("KEY_Enter", details);
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unsupported event type");
|
||||
if (type == "click") {
|
||||
ok(
|
||||
gURLBar.hasAttribute("usertyping"),
|
||||
"usertyping attribute must be set for the go button to be visible"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(gURLBar.goButton, details);
|
||||
} else if (type == "keypress") {
|
||||
EventUtils.synthesizeKey("KEY_Enter", details);
|
||||
} else {
|
||||
throw new Error("Unsupported event type");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,7 +252,8 @@ async function promiseOpenNewTab(url = "about:blank") {
|
|||
let tab = BrowserTestUtils.addTab(gBrowser, url, {
|
||||
userContextId: gUserContextIdSerial++,
|
||||
});
|
||||
let tabSwitchPromise = BrowserTestUtils.switchTab(gBrowser, tab);
|
||||
let tabSwitchPromise = promiseNewTabSwitched(tab);
|
||||
gBrowser.selectedTab = tab;
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
await tabSwitchPromise;
|
||||
return tab;
|
||||
|
|
|
@ -220,7 +220,7 @@ async function assertResult(expected) {
|
|||
Assert.equal(result.type, expected.type, "Type of autocomplete is correct");
|
||||
|
||||
if (gURLBar.value) {
|
||||
Assert.ok(gURLBar.hasAttribute("usertyping"));
|
||||
Assert.equal(gURLBar.getAttribute("usertyping"), "true");
|
||||
Assert.ok(BrowserTestUtils.is_visible(gURLBar.goButton));
|
||||
} else {
|
||||
Assert.ok(!gURLBar.hasAttribute("usertyping"));
|
||||
|
|
Загрузка…
Ссылка в новой задаче