зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1633270) for mochitest failure on test_allowContentRetargeting.html
Backed out changeset 77d5aff05a0e (bug 1633270) Backed out changeset cb53eac110d1 (bug 1633270)
This commit is contained in:
Родитель
3e4119afb1
Коммит
da3bd17056
|
@ -1372,9 +1372,6 @@ pref("pdfjs.firstRun", true);
|
|||
pref("pdfjs.previousHandler.preferredAction", 0);
|
||||
pref("pdfjs.previousHandler.alwaysAskBeforeHandling", false);
|
||||
|
||||
// Try to convert PDFs sent as octet-stream
|
||||
pref("pdfjs.handleOctetStream", true);
|
||||
|
||||
// Is the sidebar positioned ahead of the content browser
|
||||
pref("sidebar.position_start", true);
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@ Classes = [
|
|||
'contract_ids': [
|
||||
'@mozilla.org/streamconv;1?from=application/pdf&to=*/*',
|
||||
'@mozilla.org/streamconv;1?from=application/pdf&to=text/html',
|
||||
'@mozilla.org/streamconv;1?from=application/octet-stream&to=*/*',
|
||||
'@mozilla.org/streamconv;1?from=application/octet-stream&to=text/html',
|
||||
],
|
||||
'jsm': 'resource:///modules/pdfjs.js',
|
||||
'constructor': 'StreamConverterFactory',
|
||||
|
|
|
@ -1109,32 +1109,13 @@ PdfStreamConverter.prototype = {
|
|||
|
||||
getConvertedType(aFromType, aChannel) {
|
||||
const HTML = "text/html";
|
||||
let channelURI = aChannel?.URI;
|
||||
// We can be invoked for application/octet-stream; check if we want the
|
||||
// channel first:
|
||||
if (aFromType != "application/pdf") {
|
||||
let isPDF = channelURI?.QueryInterface(Ci.nsIURL).fileExtension == "pdf";
|
||||
let typeIsOctetStream = aFromType == "application/octet-stream";
|
||||
if (
|
||||
!isPDF ||
|
||||
!typeIsOctetStream ||
|
||||
!getBoolPref(PREF_PREFIX + ".handleOctetStream", false)
|
||||
) {
|
||||
throw new Components.Exception(
|
||||
"Ignore PDF.js for this download.",
|
||||
Cr.NS_ERROR_FAILURE
|
||||
);
|
||||
}
|
||||
// fall through, this appears to be a pdf.
|
||||
}
|
||||
|
||||
if (this._validateAndMaybeUpdatePDFPrefs()) {
|
||||
return HTML;
|
||||
}
|
||||
// Hm, so normally, no pdfjs. However... if this is a file: channel loaded
|
||||
// with system principal, load it anyway:
|
||||
if (channelURI?.schemeIs("file")) {
|
||||
let triggeringPrincipal = aChannel.loadInfo?.triggeringPrincipal;
|
||||
if (aChannel && aChannel.URI.schemeIs("file")) {
|
||||
let triggeringPrincipal = aChannel?.loadInfo?.triggeringPrincipal;
|
||||
if (triggeringPrincipal?.isSystemPrincipal) {
|
||||
return HTML;
|
||||
}
|
||||
|
|
|
@ -6,10 +6,6 @@ support-files =
|
|||
[browser_pdfjs_force_opening_files.js]
|
||||
[browser_pdfjs_main.js]
|
||||
[browser_pdfjs_navigation.js]
|
||||
[browser_pdfjs_octet_stream.js]
|
||||
support-files =
|
||||
file_pdfjs_object_stream.pdf
|
||||
file_pdfjs_object_stream.pdf^headers^
|
||||
[browser_pdfjs_savedialog.js]
|
||||
skip-if = verify
|
||||
[browser_pdfjs_views.js]
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const TESTROOT = getRootDirectory(gTestPath).replace(
|
||||
"chrome://mochitests/content/",
|
||||
"http://mochi.test:8888/"
|
||||
);
|
||||
|
||||
/**
|
||||
* Check that if we open a PDF with octet-stream mimetype, it can load
|
||||
* PDF.js .
|
||||
*/
|
||||
add_task(async function test_octet_stream_opens_pdfjs() {
|
||||
await SpecialPowers.pushPrefEnv({ set: [["pdfjs.handleOctetStream", true]] });
|
||||
// Get a ref to the pdf we want to open.
|
||||
let pdfURL = TESTROOT + "file_pdfjs_object_stream.pdf";
|
||||
|
||||
let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
|
||||
let handlerInfo = mimeService.getFromTypeAndExtension(
|
||||
"application/pdf",
|
||||
"pdf"
|
||||
);
|
||||
|
||||
// Make sure pdf.js is the default handler.
|
||||
is(
|
||||
handlerInfo.alwaysAskBeforeHandling,
|
||||
false,
|
||||
"pdf handler defaults to always-ask is false"
|
||||
);
|
||||
is(
|
||||
handlerInfo.preferredAction,
|
||||
Ci.nsIHandlerInfo.handleInternally,
|
||||
"pdf handler defaults to internal"
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: "about:blank" },
|
||||
async function(newTabBrowser) {
|
||||
await waitForPdfJS(newTabBrowser, pdfURL);
|
||||
is(newTabBrowser.currentURI.spec, pdfURL, "Should load pdfjs");
|
||||
}
|
||||
);
|
||||
});
|
Двоичные данные
browser/extensions/pdfjs/test/file_pdfjs_object_stream.pdf
Двоичные данные
browser/extensions/pdfjs/test/file_pdfjs_object_stream.pdf
Двоичный файл не отображается.
|
@ -1,2 +0,0 @@
|
|||
Content-Type: application/octet-stream
|
||||
|
|
@ -1686,13 +1686,6 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
|
|||
alwaysAsk = (action != nsIMIMEInfo::saveToDisk);
|
||||
}
|
||||
|
||||
// If we're not asking, check we actually know what to do:
|
||||
if (!alwaysAsk) {
|
||||
alwaysAsk = action != nsIMIMEInfo::saveToDisk &&
|
||||
action != nsIMIMEInfo::useHelperApp &&
|
||||
action != nsIMIMEInfo::useSystemDefault;
|
||||
}
|
||||
|
||||
// if we were told that we _must_ save to disk without asking, all the stuff
|
||||
// before this is irrelevant; override it
|
||||
if (mForceSave) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче