forked from mirrors/gecko-dev
Instead of `<xul:hbox class="textbox-input-box">`, consumers now should use `<xul:moz-input-box />`. This covers the normal case and also handles [spellcheck=true] while sharing much of the code within one class. MozReview-Commit-ID: DjvT8sFq3SQ --HG-- rename : toolkit/content/widgets/textbox.xml => toolkit/content/widgets/textbox.js
63 lines
2.5 KiB
JavaScript
63 lines
2.5 KiB
JavaScript
"use strict";
|
|
|
|
let clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
|
|
|
|
add_task(async function() {
|
|
const kURLs = [
|
|
"http://example.com/1",
|
|
"http://example.org/2\n",
|
|
"http://\nexample.com/3\n",
|
|
];
|
|
for (let url of kURLs) {
|
|
await BrowserTestUtils.withNewTab("about:blank", async function(browser) {
|
|
gURLBar.focus();
|
|
await new Promise((resolve, reject) => {
|
|
waitForClipboard(url, function() {
|
|
clipboardHelper.copyString(url);
|
|
}, resolve,
|
|
() => reject(new Error(`Failed to copy string '${url}' to clipboard`))
|
|
);
|
|
});
|
|
let textBox = document.getAnonymousElementByAttribute(gURLBar,
|
|
"anonid", "moz-input-box");
|
|
let cxmenu = textBox.menupopup;
|
|
let cxmenuPromise = BrowserTestUtils.waitForEvent(cxmenu, "popupshown");
|
|
EventUtils.synthesizeMouseAtCenter(gURLBar, {type: "contextmenu", button: 2});
|
|
await cxmenuPromise;
|
|
let menuitem = textBox.getMenuItem("paste-and-go");
|
|
let browserLoadedPromise = BrowserTestUtils.browserLoaded(browser, false, url.replace(/\n/g, ""));
|
|
EventUtils.synthesizeMouseAtCenter(menuitem, {});
|
|
// Using toSource in order to get the newlines escaped:
|
|
info("Paste and go, loading " + url.toSource());
|
|
await browserLoadedPromise;
|
|
ok(true, "Successfully loaded " + url);
|
|
});
|
|
}
|
|
});
|
|
|
|
add_task(async function() {
|
|
const url = "http://example.com/4\u2028";
|
|
await BrowserTestUtils.withNewTab("about:blank", async function(browser) {
|
|
gURLBar.focus();
|
|
await new Promise((resolve, reject) => {
|
|
waitForClipboard(url, function() {
|
|
clipboardHelper.copyString(url);
|
|
}, resolve,
|
|
() => reject(new Error(`Failed to copy string '${url}' to clipboard`))
|
|
);
|
|
});
|
|
let textBox = document.getAnonymousElementByAttribute(gURLBar,
|
|
"anonid", "moz-input-box");
|
|
let cxmenu = textBox.menupopup;
|
|
let cxmenuPromise = BrowserTestUtils.waitForEvent(cxmenu, "popupshown");
|
|
EventUtils.synthesizeMouseAtCenter(gURLBar, {type: "contextmenu", button: 2});
|
|
await cxmenuPromise;
|
|
let menuitem = textBox.getMenuItem("paste-and-go");
|
|
let browserLoadedPromise = BrowserTestUtils.browserLoaded(browser, false, url.replace(/\u2028/g, ""));
|
|
EventUtils.synthesizeMouseAtCenter(menuitem, {});
|
|
// Using toSource in order to get the newlines escaped:
|
|
info("Paste and go, loading " + url.toSource());
|
|
await browserLoadedPromise;
|
|
ok(true, "Successfully loaded " + url);
|
|
});
|
|
});
|