Backed out changeset 671cc9eb7842 (bug 1854747) for bc failure browser_save_filenames.js

This commit is contained in:
Narcis Beleuzu 2023-09-29 19:43:07 +03:00
Родитель 56f31dc67a
Коммит 0e81f29204
6 изменённых файлов: 22 добавлений и 46 удалений

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

@ -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.ini",
"test/mochitest.ini",
"test/pointerevents/mochitest.ini",
]

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

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

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

@ -249,6 +249,9 @@ skip-if =
[test_offsetxy.html]
[test_onerror_handler_args.html]
[test_passive_listeners.html]
[test_paste_image.html]
skip-if = headless # Bug 1405869
toolkit == 'android' # Image type isn't supported
[test_moving_and_expanding_selection_per_page.html]
support-files = window_empty_document.html
[test_scroll_per_page.html]

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

@ -25,6 +25,7 @@
info("returned=" + counter + " images.length=" + images.length);
if (counter == images.length) {
info("test finish");
SimpleTest.finish();
}
};
@ -79,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');
@ -99,26 +98,16 @@
ok(clipboard.hasDataMatchingFlavors(["image/png"], clipboard.kGlobalClipboard),
"clipboard contains image");
let promise = new Promise(resolve => {
window.addEventListener("paste", (e) => {
isDeeply(e.clipboardData.types,
(navigator.platform.includes("Win") && imageAsFileEnabled) ?
["application/x-moz-file", "Files"] : ["text/html", "text/plain", "Files"]);
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;
}
function onPaste(e, imageAsFileEnabled) {
function onPaste(e) {
var imageTester = new ImageTester;
testFiles(e, imageTester, imageAsFileEnabled);
testFiles(e, imageTester);
testItems(e, imageTester);
imageTester.test();
}
@ -142,7 +131,7 @@
}
}
function testFiles(e, imageTester, imageAsFileEnabled) {
function testFiles(e, imageTester) {
var files = e.clipboardData.files;
is(files, e.clipboardData.files,
@ -152,7 +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");
is(file.name, (navigator.platform.includes("Win") && imageAsFileEnabled) ? "Untitled.png" : "image.png", "Check filename");
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", "Correct filename");
}
is(file.type, "image/png", "This file should be a image/png");
testSlice(file);
imageTester.add(file);
@ -180,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
#---------------------------------------------------------------------------