Backed out changeset 1e91f547f0c7 (bug 1854747) for causing bc failures at browser_save_filenames.js on a CLOSED TREE

This commit is contained in:
Cristina Horotan 2023-10-05 22:22:27 +03:00
Родитель c801c3c9fd
Коммит 64d32032ea
7 изменённых файлов: 37 добавлений и 73 удалений

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

@ -40,7 +40,6 @@
#include "nsContentCID.h"
#ifdef XP_WIN
# include "mozilla/StaticPrefs_clipboard.h"
# include "nsCExternalHandlerService.h"
# include "nsEscape.h"
# include "nsIMIMEInfo.h"
@ -503,10 +502,8 @@ nsresult nsCopySupport::ImageCopy(nsIImageLoadingContent* aImageElement,
}
#ifdef XP_WIN
if (StaticPrefs::clipboard_imageAsFile_enabled()) {
rv = AppendImagePromise(trans, imgRequest, aImageElement);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = AppendImagePromise(trans, imgRequest, aImageElement);
NS_ENSURE_SUCCESS(rv, rv);
#endif
// copy the image data onto the transferable

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

@ -16,7 +16,6 @@ BROWSER_CHROME_MANIFESTS += [
]
MOCHITEST_MANIFESTS += [
"test/clipboard/mochitest.toml",
"test/mochitest.toml",
"test/pointerevents/mochitest.toml",
]

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

@ -1,7 +0,0 @@
[DEFAULT]
["test_paste_image.html"]
skip-if = [
"headless", # Bug 1405869
"os == 'android'", # Image type isn't supported
]

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

@ -483,6 +483,12 @@ support-files = ["window_empty_document.html"]
["test_passive_listeners.html"]
["test_paste_image.html"]
skip-if = [
"headless", # Bug 1405869
"os == 'android'", # Image type isn't supported
]
["test_scroll_per_page.html"]
support-files = ["window_empty_document.html"]
skip-if = ["os == 'android'"] # fail

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

@ -14,9 +14,9 @@
images.push(aFile);
};
this.test = async function() {
this.test = function() {
for (var i = 0; i < images.length; i++) {
await testImageSize(images[i]);
testImageSize(images[i]);
}
};
@ -25,31 +25,28 @@
info("returned=" + counter + " images.length=" + images.length);
if (counter == images.length) {
info("test finish");
SimpleTest.finish();
}
};
async function testImageSize(aFile) {
function testImageSize(aFile) {
var source = window.URL.createObjectURL(aFile);
var image = new Image();
image.src = source;
var imageTester = that;
let promise = new Promise(resolve => {
image.addEventListener("load", function(e) {
is(this.width, 62, "Check generated image width");
is(this.height, 71, "Check generated image height");
image.onload = function() {
is(this.width, 62, "Check generated image width");
is(this.height, 71, "Check generated image height");
// This fails on OSX only.
if (!navigator.platform.includes("Mac")) {
testImageCanvas(image);
}
// This fails on OSX only.
if (!navigator.platform.includes("Mac")) {
testImageCanvas(image);
}
imageTester.returned();
resolve();
}, { once: true });
});
imageTester.returned();
}
document.body.appendChild(image);
await promise;
};
function testImageCanvas(aImage) {
@ -83,10 +80,8 @@
documentViewer.copyImage(documentViewer.COPY_IMAGE_ALL);
}
async function doTest(imageAsFileEnabled) {
await SpecialPowers.pushPrefEnv({
set: [["clipboard.imageAsFile.enabled", imageAsFileEnabled]],
});
function doTest() {
SimpleTest.waitForExplicitFinish();
copyImage('image');
@ -103,30 +98,18 @@
ok(clipboard.hasDataMatchingFlavors(["image/png"], clipboard.kGlobalClipboard),
"clipboard contains image");
let promise = new Promise(resolve => {
window.addEventListener("paste", async (e) => {
isDeeply(e.clipboardData.types,
(navigator.platform.includes("Win") && imageAsFileEnabled) ?
["application/x-moz-file", "Files"] : ["text/html", "text/plain", "Files"]);
await onPaste(e, imageAsFileEnabled);
resolve();
}, { once: true });
});
window.addEventListener("paste", onPaste);
var textarea = SpecialPowers.wrap(document.getElementById('textarea'));
textarea.focus();
textarea.editor.paste(clipboard.kGlobalClipboard);
await promise;
clipboard.emptyClipboard(clipboard.kGlobalClipboard);
}
async function onPaste(e, imageAsFileEnabled) {
function onPaste(e) {
var imageTester = new ImageTester;
testFiles(e, imageTester, imageAsFileEnabled);
testFiles(e, imageTester);
testItems(e, imageTester);
await imageTester.test();
imageTester.test();
}
function testItems(e, imageTester) {
@ -148,7 +131,7 @@
}
}
function testFiles(e, imageTester, imageAsFileEnabled) {
function testFiles(e, imageTester) {
var files = e.clipboardData.files;
is(files, e.clipboardData.files,
@ -158,12 +141,15 @@
var file = files[i];
ok(file instanceof File, ".files should contain only File objects");
ok(file.size > 0, "This file shouldn't have size 0");
if (navigator.platform.includes("Win") && imageAsFileEnabled) {
ok(file.name.startsWith("Untitled") && file.name.endsWith(".png"),
`Check filename, got "${file.name}"`);
if (navigator.platform.includes("Win")) {
// On Windows the pasted file is (sometimes?) produced from the Windows only
// file promise added by AppendImagePromise.
ok(file.name == "image.png" || (file.name.startsWith("Untitled") && file.name.endsWith(".png")),
`Correct filename, got "${file.name}"`);
} else {
is(file.name, "image.png", "Check filename");
is(file.name, "image.png", "Correct filename");
}
is(file.type, "image/png", "This file should be a image/png");
testSlice(file);
imageTester.add(file);
@ -191,16 +177,8 @@
is(blob.type, "image/png", ".slice @type check");
}
add_task(async function test_imageAsFile_enabled() {
await doTest(true);
});
add_task(async function test_imageAsFile_disabled() {
await doTest(false);
});
</script>
<body>
<body onload="doTest();">
<img id="image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAABHCA
IAAADQjmMaAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3goUAwAgSAORBwAAABl0RVh0Q29
tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAABPSURBVGje7c4BDQAACAOga//OmuMbJGAurTbq

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

@ -1857,12 +1857,6 @@
type: bool
value: false
mirror: always
# Whether to put a file promise onto the clipboard when copying images on Windows
- name: clipboard.imageAsFile.enabled
type: bool
value: @IS_NOT_EARLY_BETA_OR_EARLIER@
mirror: always
#endif
#---------------------------------------------------------------------------

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

@ -372,10 +372,7 @@ if (AppConstants.platform != "macosx") {
// This test checks that copying an image provides the right filename
// for pasting to the local file system. This is only implemented on Windows.
const imageAsFileEnabled = SpecialPowers.getBoolPref(
"clipboard.imageAsFile.enabled"
);
if (AppConstants.platform == "win" && imageAsFileEnabled) {
if (AppConstants.platform == "win") {
add_task(async function copy_image() {
for (let idx = 0; idx < expectedItems.length; idx++) {
if (!expectedItems[idx].draggable) {