зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1411502 - Enable browser_jsterm_copy_command.js in new frontend; r=Honza.
MozReview-Commit-ID: EsQsov5y7cD --HG-- extra : rebase_source : e2af7cc3bda73052b14c8c6a5450b184b734860a
This commit is contained in:
Родитель
3ce4a01fb7
Коммит
827151f951
|
@ -199,9 +199,6 @@ skip-if = true # Bug 1403188
|
|||
[browser_jsterm_autocomplete_helpers.js]
|
||||
[browser_jsterm_autocomplete-properties-with-non-alphanumeric-names.js]
|
||||
[browser_jsterm_copy_command.js]
|
||||
skip-if = true
|
||||
subsuite = clipboard
|
||||
# old console skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
|
||||
[browser_jsterm_dollar.js]
|
||||
[browser_jsterm_history_persist.js]
|
||||
[browser_jsterm_inspect.js]
|
||||
|
|
|
@ -7,70 +7,48 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var gWebConsole, gJSTerm;
|
||||
const text = "Lorem ipsum dolor sit amet, consectetur adipisicing " +
|
||||
"elit, sed do eiusmod tempor incididunt ut labore et dolore magna " +
|
||||
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco " +
|
||||
"laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " +
|
||||
"dolor in reprehenderit in voluptate velit esse cillum dolore eu " +
|
||||
"fugiat nulla pariatur. Excepteur sint occaecat cupidatat non " +
|
||||
"proident, sunt in culpa qui officia deserunt mollit anim id est laborum." + new Date();
|
||||
|
||||
var TEXT = "Lorem ipsum dolor sit amet, consectetur adipisicing " +
|
||||
"elit, sed do eiusmod tempor incididunt ut labore et dolore magna " +
|
||||
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco " +
|
||||
"laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " +
|
||||
"dolor in reprehenderit in voluptate velit esse cillum dolore eu " +
|
||||
"fugiat nulla pariatur. Excepteur sint occaecat cupidatat non " +
|
||||
"proident, sunt in culpa qui officia deserunt mollit anim id est laborum." +
|
||||
new Date();
|
||||
const id = "select-me";
|
||||
const TEST_URI = `data:text/html;charset=utf-8,
|
||||
<body>
|
||||
<div>
|
||||
<h1>Testing copy command</h1>
|
||||
<p>This is some example text</p>
|
||||
<p id="${id}">${text}</p>
|
||||
</div>
|
||||
<div><p></p></div>
|
||||
</body>`;
|
||||
|
||||
var ID = "select-me";
|
||||
add_task(async function () {
|
||||
let {jsterm} = await openNewTabAndConsole(TEST_URI);
|
||||
const random = Math.random();
|
||||
let string = "Text: " + random;
|
||||
let obj = {a: 1, b: "foo", c: random};
|
||||
|
||||
add_task(function* init() {
|
||||
yield loadTab("data:text/html;charset=utf-8," +
|
||||
"<body>" +
|
||||
" <div>" +
|
||||
" <h1>Testing copy command</h1>" +
|
||||
" <p>This is some example text</p>" +
|
||||
" <p id='select-me'>" + TEXT + "</p>" +
|
||||
" </div>" +
|
||||
" <div><p></p></div>" +
|
||||
"</body>");
|
||||
await testCopy(jsterm, random, random.toString());
|
||||
await testCopy(jsterm, JSON.stringify(string), string);
|
||||
await testCopy(jsterm, obj.toSource(), JSON.stringify(obj, null, " "));
|
||||
|
||||
gWebConsole = yield openConsole();
|
||||
gJSTerm = gWebConsole.jsterm;
|
||||
const outerHTML = await ContentTask.spawn(gBrowser.selectedBrowser, id,
|
||||
function (elementId) {
|
||||
return content.document.getElementById(elementId).outerHTML;
|
||||
}
|
||||
);
|
||||
await testCopy(jsterm, `$("#${id}")`, outerHTML);
|
||||
});
|
||||
|
||||
add_task(function* testCopy() {
|
||||
let RANDOM = Math.random();
|
||||
let string = "Text: " + RANDOM;
|
||||
let obj = {a: 1, b: "foo", c: RANDOM};
|
||||
|
||||
let samples = [
|
||||
[RANDOM, RANDOM],
|
||||
[JSON.stringify(string), string],
|
||||
[obj.toSource(), JSON.stringify(obj, null, " ")],
|
||||
[
|
||||
"$('#" + ID + "')",
|
||||
content.document.getElementById(ID).outerHTML
|
||||
]
|
||||
];
|
||||
for (let [source, reference] of samples) {
|
||||
let deferredResult = defer();
|
||||
|
||||
SimpleTest.waitForClipboard(
|
||||
"" + reference,
|
||||
() => {
|
||||
let command = "copy(" + source + ")";
|
||||
info("Attempting to copy: " + source);
|
||||
info("Executing command: " + command);
|
||||
gJSTerm.execute(command, msg => {
|
||||
is(msg, undefined, "Command success: " + command);
|
||||
});
|
||||
},
|
||||
deferredResult.resolve,
|
||||
deferredResult.reject);
|
||||
|
||||
yield deferredResult.promise;
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function* cleanup() {
|
||||
gWebConsole = gJSTerm = null;
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
finishTest();
|
||||
});
|
||||
function testCopy(jsterm, stringToCopy, expectedResult) {
|
||||
return waitForClipboardPromise(() => {
|
||||
info(`Attempting to copy: "${stringToCopy}"`);
|
||||
const command = `copy(${stringToCopy})`;
|
||||
info(`Executing command: "${command}"`);
|
||||
jsterm.execute(command);
|
||||
}, expectedResult);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче