forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1185358: Replace any whitespace chars with space. r=adw
Differential Revision: https://phabricator.services.mozilla.com/D105726
- Loading branch information
Daisuke Akatsuka
committed
Feb 22, 2021
1 parent
6cb8765
commit feba0e3
Showing
3 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
browser/components/urlbar/tests/browser/browser_paste_multi_lines.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
"use strict"; | ||
|
||
// Test handling whitespace chars such as "\n”. | ||
|
||
const TEST_DATA = [ | ||
{ | ||
input: "this is a\ntest", | ||
expected: "this is a test", | ||
}, | ||
{ | ||
input: "this is a\n\ttest", | ||
expected: "this is a test", | ||
}, | ||
{ | ||
input: "http:\n//\nexample.\ncom", | ||
expected: "http://example.com", | ||
}, | ||
{ | ||
input: "htp:example.\ncom", | ||
expected: "htp:example.com", | ||
}, | ||
{ | ||
input: "example.\ncom", | ||
expected: "example.com", | ||
}, | ||
{ | ||
input: "http://example.com/foo bar/", | ||
expected: "http://example.com/foo bar/", | ||
}, | ||
{ | ||
input: "javasc\nript:\nalert(1)", | ||
expected: "alert(1)", | ||
}, | ||
]; | ||
|
||
add_task(async function test_paste_multi_lines() { | ||
for (const testData of TEST_DATA) { | ||
gURLBar.value = ""; | ||
gURLBar.focus(); | ||
|
||
await paste(testData.input); | ||
|
||
Assert.equal(gURLBar.value, testData.expected, "Pasted value is correct"); | ||
} | ||
}); | ||
|
||
async function paste(input) { | ||
await SimpleTest.promiseClipboardChange(input, () => { | ||
clipboardHelper.copyString(input); | ||
}); | ||
|
||
document.commandDispatcher | ||
.getControllerForCommand("cmd_paste") | ||
.doCommand("cmd_paste"); | ||
} |