Bug 1719387 - Make `test_bug795418-2.html` request `text/unicode` flavor in the headless mode r=smaug

Until fixing bug 1686012, clipboard in the headless mode does not support
"text/html" flavor.  Therefore, the `waitForClipboard` in the test does not
get expected value as `aData` in the first callback.

So, it should request `text/unicode` in the headless mode.

Depends on D119483

Differential Revision: https://phabricator.services.mozilla.com/D119484
This commit is contained in:
Masayuki Nakano 2021-07-12 03:55:21 +00:00
Родитель f9bedeed22
Коммит a81636618b
2 изменённых файлов: 16 добавлений и 15 удалений

Просмотреть файл

@ -27,15 +27,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=795418
/** Test for Bug 795418 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("copySource");
var sel = window.getSelection();
sel.removeAllRanges();
// Select the text from the text node in div.
var r = document.createRange();
r.setStart(div.firstChild, 0);
r.setEnd(div.firstChild, 9);
sel.addRange(r);
const div = document.getElementById("copySource");
getSelection().setBaseAndExtent(div.firstChild, 0, div.firstChild, "Copy this".length);
info(`Selected test: "${getSelection().getRangeAt(0).toString()}"`);
function checkResult() {
var iframe = document.querySelector("iframe");
@ -66,20 +60,23 @@ SimpleTest.waitForFocus(function() {
SimpleTest.waitForClipboard(
aData => {
// XXX Oddly, specifying `r.toString()` causes timeout in headless mode.
info(`copied text: "${aData}"`);
return true;
if (aData.includes(`${getSelection().getRangeAt(0)?.toString()}`)) {
return true;
}
info(`Text in the clipboard: "${aData}"`);
return false;
},
function setup() {
synthesizeKey("C", {accelKey: true});
synthesizeKey("c", {accelKey: true});
},
function onSuccess() {
setTimeout(pasteQuote, 0);
SimpleTest.executeSoon(pasteQuote);
},
function onFailure() {
SimpleTest.finish();
},
"text/html"
// TODO: bug 1686012
SpecialPowers.isHeadless ? "text/unicode" : "text/html"
);
});

Просмотреть файл

@ -712,6 +712,10 @@ class SpecialPowersChild extends JSWindowActorChild {
return Cr;
}
get isHeadless() {
return Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo).isHeadless;
}
get addProfilerMarker() {
return ChromeUtils.addProfilerMarker;
}