[Firefox addon] Change the minimum supported version to Firefox 38 and remove a bunch old no longer necessary fallback code
From the discussion in issue 7386, it wasn't really clear if we can restrict addon support to Firefox `45` (i.e. the version that corresponds to the *current* ESR version). However, we have a bunch of code for *very* old Firefox versions. Hence this patch changes the minimum supported version to Firefox `38` (which was released on `2015-05-12`, and correspond to the *previous* ESR version), and removes code that only applies to old Firefox versions. Regardless what we end up deciding regarding addon support for previous Firefox versions, given the amount of code that even the Firefox `>= 38` condition lets us remove, I certainly think that there is value in doing this.
This commit is contained in:
parent
64a409b539
commit
d3d3bb9695
@ -65,32 +65,15 @@ function getFindBar(domWindow) {
|
|||||||
if (PdfjsContentUtils.isRemote) {
|
if (PdfjsContentUtils.isRemote) {
|
||||||
throw new Error('FindBar is not accessible from the content process.');
|
throw new Error('FindBar is not accessible from the content process.');
|
||||||
}
|
}
|
||||||
var browser = getContainingBrowser(domWindow);
|
|
||||||
try {
|
try {
|
||||||
|
var browser = getContainingBrowser(domWindow);
|
||||||
var tabbrowser = browser.getTabBrowser();
|
var tabbrowser = browser.getTabBrowser();
|
||||||
var tab;
|
var tab = tabbrowser.getTabForBrowser(browser);
|
||||||
//#if MOZCENTRAL
|
|
||||||
tab = tabbrowser.getTabForBrowser(browser);
|
|
||||||
//#else
|
|
||||||
if (tabbrowser.getTabForBrowser) {
|
|
||||||
tab = tabbrowser.getTabForBrowser(browser);
|
|
||||||
} else {
|
|
||||||
// _getTabForBrowser is depreciated in Firefox 35, see
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1039500.
|
|
||||||
tab = tabbrowser._getTabForBrowser(browser);
|
|
||||||
}
|
|
||||||
//#endif
|
|
||||||
return tabbrowser.getFindBar(tab);
|
return tabbrowser.getFindBar(tab);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
try {
|
// Suppress errors for PDF files opened in the bookmark sidebar, see
|
||||||
// FF22 has no _getTabForBrowser, and FF24 has no getFindBar
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1248959.
|
||||||
var chromeWindow = browser.ownerDocument.defaultView;
|
return null;
|
||||||
return chromeWindow.gFindBar;
|
|
||||||
} catch (ex) {
|
|
||||||
// Suppress errors for PDF files opened in the bookmark sidebar, see
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1248959.
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,26 +148,6 @@ function getLocalizedString(strings, id, property) {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeContentReadable(obj, window) {
|
|
||||||
//#if MOZCENTRAL
|
|
||||||
/* jshint -W027 */
|
|
||||||
return Cu.cloneInto(obj, window);
|
|
||||||
//#else
|
|
||||||
if (Cu.cloneInto) {
|
|
||||||
return Cu.cloneInto(obj, window);
|
|
||||||
}
|
|
||||||
if (typeof obj !== 'object' || obj === null) {
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
var expose = {};
|
|
||||||
for (let k in obj) {
|
|
||||||
expose[k] = 'r';
|
|
||||||
}
|
|
||||||
obj.__exposedProps__ = expose;
|
|
||||||
return obj;
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
function createNewChannel(uri, node, principal) {
|
function createNewChannel(uri, node, principal) {
|
||||||
//#if !MOZCENTRAL
|
//#if !MOZCENTRAL
|
||||||
if (NetUtil.newChannel2) {
|
if (NetUtil.newChannel2) {
|
||||||
@ -197,12 +160,6 @@ function createNewChannel(uri, node, principal) {
|
|||||||
Ci.nsILoadInfo.SEC_NORMAL,
|
Ci.nsILoadInfo.SEC_NORMAL,
|
||||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||||
}
|
}
|
||||||
// The signature of `NetUtil.newChannel` changed in Firefox 38,
|
|
||||||
// see https://bugzilla.mozilla.org/show_bug.cgi?id=1125618.
|
|
||||||
var ffVersion = parseInt(Services.appinfo.platformVersion);
|
|
||||||
if (ffVersion < 38) {
|
|
||||||
return NetUtil.newChannel(uri);
|
|
||||||
}
|
|
||||||
//#endif
|
//#endif
|
||||||
return NetUtil.newChannel({
|
return NetUtil.newChannel({
|
||||||
uri: uri,
|
uri: uri,
|
||||||
@ -294,13 +251,6 @@ function ChromeActions(domWindow, contentDispositionFilename) {
|
|||||||
|
|
||||||
ChromeActions.prototype = {
|
ChromeActions.prototype = {
|
||||||
isInPrivateBrowsing: function() {
|
isInPrivateBrowsing: function() {
|
||||||
//#if !MOZCENTRAL
|
|
||||||
if (!PrivateBrowsingUtils.isContentWindowPrivate) {
|
|
||||||
// pbu.isContentWindowPrivate was not supported prior Firefox 35.
|
|
||||||
// (https://bugzilla.mozilla.org/show_bug.cgi?id=1069059)
|
|
||||||
return PrivateBrowsingUtils.isWindowPrivate(this.domWindow);
|
|
||||||
}
|
|
||||||
//#endif
|
|
||||||
return PrivateBrowsingUtils.isContentWindowPrivate(this.domWindow);
|
return PrivateBrowsingUtils.isContentWindowPrivate(this.domWindow);
|
||||||
},
|
},
|
||||||
download: function(data, sendResponse) {
|
download: function(data, sendResponse) {
|
||||||
@ -423,11 +373,7 @@ ChromeActions.prototype = {
|
|||||||
return (!!prefBrowser && prefGfx);
|
return (!!prefBrowser && prefGfx);
|
||||||
},
|
},
|
||||||
supportsDocumentColors: function() {
|
supportsDocumentColors: function() {
|
||||||
if (getIntPref('browser.display.document_color_use', 0) === 2 ||
|
return getIntPref('browser.display.document_color_use', 0) !== 2;
|
||||||
!getBoolPref('browser.display.use_document_colors', true)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
supportedMouseWheelZoomModifierKeys: function() {
|
supportedMouseWheelZoomModifierKeys: function() {
|
||||||
return {
|
return {
|
||||||
@ -839,7 +785,7 @@ RequestListener.prototype.receive = function(event) {
|
|||||||
var response;
|
var response;
|
||||||
if (sync) {
|
if (sync) {
|
||||||
response = actions[action].call(this.actions, data);
|
response = actions[action].call(this.actions, data);
|
||||||
event.detail.response = makeContentReadable(response, doc.defaultView);
|
event.detail.response = Cu.cloneInto(response, doc.defaultView);
|
||||||
} else {
|
} else {
|
||||||
if (!event.detail.responseExpected) {
|
if (!event.detail.responseExpected) {
|
||||||
doc.documentElement.removeChild(message);
|
doc.documentElement.removeChild(message);
|
||||||
@ -848,8 +794,7 @@ RequestListener.prototype.receive = function(event) {
|
|||||||
response = function sendResponse(response) {
|
response = function sendResponse(response) {
|
||||||
try {
|
try {
|
||||||
var listener = doc.createEvent('CustomEvent');
|
var listener = doc.createEvent('CustomEvent');
|
||||||
let detail = makeContentReadable({response: response},
|
let detail = Cu.cloneInto({ response: response }, doc.defaultView);
|
||||||
doc.defaultView);
|
|
||||||
listener.initCustomEvent('pdf.js.response', true, false, detail);
|
listener.initCustomEvent('pdf.js.response', true, false, detail);
|
||||||
return message.dispatchEvent(listener);
|
return message.dispatchEvent(listener);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -893,7 +838,7 @@ FindEventManager.prototype.receiveMessage = function(msg) {
|
|||||||
var type = msg.data.type;
|
var type = msg.data.type;
|
||||||
var contentWindow = this.contentWindow;
|
var contentWindow = this.contentWindow;
|
||||||
|
|
||||||
detail = makeContentReadable(detail, contentWindow);
|
detail = Cu.cloneInto(detail, contentWindow);
|
||||||
var forward = contentWindow.document.createEvent('CustomEvent');
|
var forward = contentWindow.document.createEvent('CustomEvent');
|
||||||
forward.initCustomEvent(type, true, true, detail);
|
forward.initCustomEvent(type, true, true, detail);
|
||||||
contentWindow.dispatchEvent(forward);
|
contentWindow.dispatchEvent(forward);
|
||||||
@ -1016,11 +961,6 @@ PdfStreamConverter.prototype = {
|
|||||||
aRequest.setResponseHeader('Content-Security-Policy', '', false);
|
aRequest.setResponseHeader('Content-Security-Policy', '', false);
|
||||||
aRequest.setResponseHeader('Content-Security-Policy-Report-Only', '',
|
aRequest.setResponseHeader('Content-Security-Policy-Report-Only', '',
|
||||||
false);
|
false);
|
||||||
//#if !MOZCENTRAL
|
|
||||||
aRequest.setResponseHeader('X-Content-Security-Policy', '', false);
|
|
||||||
aRequest.setResponseHeader('X-Content-Security-Policy-Report-Only', '',
|
|
||||||
false);
|
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PdfJsTelemetry.onViewerIsUsed();
|
PdfJsTelemetry.onViewerIsUsed();
|
||||||
@ -1085,26 +1025,22 @@ PdfStreamConverter.prototype = {
|
|||||||
channel.loadGroup = aRequest.loadGroup;
|
channel.loadGroup = aRequest.loadGroup;
|
||||||
channel.loadInfo.originAttributes = aRequest.loadInfo.originAttributes;
|
channel.loadInfo.originAttributes = aRequest.loadInfo.originAttributes;
|
||||||
|
|
||||||
// We can use resource principal when data is fetched by the chrome
|
// We can use the resource principal when data is fetched by the chrome,
|
||||||
// make sure we reuse the origin attributes from the request channel to keep
|
// e.g. useful for NoScript. Make make sure we reuse the origin attributes
|
||||||
// isolation consistent.
|
// from the request channel to keep isolation consistent.
|
||||||
// e.g. useful for NoScript
|
|
||||||
var ssm = Cc['@mozilla.org/scriptsecuritymanager;1']
|
var ssm = Cc['@mozilla.org/scriptsecuritymanager;1']
|
||||||
.getService(Ci.nsIScriptSecurityManager);
|
.getService(Ci.nsIScriptSecurityManager);
|
||||||
var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE, null, null);
|
var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE, null, null);
|
||||||
var attrs = aRequest.loadInfo.originAttributes;
|
|
||||||
var resourcePrincipal;
|
var resourcePrincipal;
|
||||||
//#if MOZCENTRAL
|
//#if MOZCENTRAL
|
||||||
resourcePrincipal = ssm.createCodebasePrincipal(uri, attrs);
|
resourcePrincipal =
|
||||||
|
ssm.createCodebasePrincipal(uri, aRequest.loadInfo.originAttributes);
|
||||||
//#else
|
//#else
|
||||||
// FF16 and below had getCodebasePrincipal, it was replaced by
|
// FF43 replaced `getCodebasePrincipal` with `createCodebasePrincipal`,
|
||||||
// getNoAppCodebasePrincipal (bug 758258).
|
// see https://bugzilla.mozilla.org/show_bug.cgi?id=1165272.
|
||||||
// FF43 then replaced getNoAppCodebasePrincipal with
|
|
||||||
// createCodebasePrincipal (bug 1165272).
|
|
||||||
if ('createCodebasePrincipal' in ssm) {
|
if ('createCodebasePrincipal' in ssm) {
|
||||||
resourcePrincipal = ssm.createCodebasePrincipal(uri, attrs);
|
resourcePrincipal =
|
||||||
} else if ('getNoAppCodebasePrincipal' in ssm) {
|
ssm.createCodebasePrincipal(uri, aRequest.loadInfo.originAttributes);
|
||||||
resourcePrincipal = ssm.getNoAppCodebasePrincipal(uri);
|
|
||||||
} else {
|
} else {
|
||||||
resourcePrincipal = ssm.getCodebasePrincipal(uri);
|
resourcePrincipal = ssm.getCodebasePrincipal(uri);
|
||||||
}
|
}
|
||||||
|
@ -170,18 +170,7 @@ var PdfjsChromeUtils = {
|
|||||||
_findbarFromMessage: function(aMsg) {
|
_findbarFromMessage: function(aMsg) {
|
||||||
let browser = aMsg.target;
|
let browser = aMsg.target;
|
||||||
let tabbrowser = browser.getTabBrowser();
|
let tabbrowser = browser.getTabBrowser();
|
||||||
let tab;
|
let tab = tabbrowser.getTabForBrowser(browser);
|
||||||
//#if MOZCENTRAL
|
|
||||||
tab = tabbrowser.getTabForBrowser(browser);
|
|
||||||
//#else
|
|
||||||
if (tabbrowser.getTabForBrowser) {
|
|
||||||
tab = tabbrowser.getTabForBrowser(browser);
|
|
||||||
} else {
|
|
||||||
// _getTabForBrowser is deprecated in Firefox 35, see
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1039500.
|
|
||||||
tab = tabbrowser._getTabForBrowser(browser);
|
|
||||||
}
|
|
||||||
//#endif
|
|
||||||
return tabbrowser.getFindBar(tab);
|
return tabbrowser.getFindBar(tab);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
<em:targetApplication>
|
<em:targetApplication>
|
||||||
<Description>
|
<Description>
|
||||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||||
<em:minVersion>10.0</em:minVersion>
|
<em:minVersion>38.0</em:minVersion>
|
||||||
<em:maxVersion>46.0a1</em:maxVersion>
|
<em:maxVersion>50.0a1</em:maxVersion>
|
||||||
</Description>
|
</Description>
|
||||||
</em:targetApplication>
|
</em:targetApplication>
|
||||||
|
|
||||||
@ -31,8 +31,8 @@
|
|||||||
<em:targetApplication>
|
<em:targetApplication>
|
||||||
<Description>
|
<Description>
|
||||||
<em:id>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</em:id>
|
<em:id>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</em:id>
|
||||||
<em:minVersion>11.0</em:minVersion>
|
<em:minVersion>38.0</em:minVersion>
|
||||||
<em:maxVersion>46.0a1</em:maxVersion>
|
<em:maxVersion>50.0a1</em:maxVersion>
|
||||||
</Description>
|
</Description>
|
||||||
</em:targetApplication>
|
</em:targetApplication>
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
<em:targetApplication>
|
<em:targetApplication>
|
||||||
<RDF:Description>
|
<RDF:Description>
|
||||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||||
<em:minVersion>10.0</em:minVersion>
|
<em:minVersion>38.0</em:minVersion>
|
||||||
<em:maxVersion>46.0</em:maxVersion>
|
<em:maxVersion>50.0</em:maxVersion>
|
||||||
<!-- Use the raw link for updates so we we can use SSL. -->
|
<!-- Use the raw link for updates so we we can use SSL. -->
|
||||||
<em:updateLink>https://raw.githubusercontent.com/mozilla/pdf.js/gh-pages/extensions/firefox/pdf.js.xpi</em:updateLink>
|
<em:updateLink>https://raw.githubusercontent.com/mozilla/pdf.js/gh-pages/extensions/firefox/pdf.js.xpi</em:updateLink>
|
||||||
</RDF:Description>
|
</RDF:Description>
|
||||||
@ -25,8 +25,8 @@
|
|||||||
<em:targetApplication>
|
<em:targetApplication>
|
||||||
<RDF:Description>
|
<RDF:Description>
|
||||||
<em:id>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</em:id>
|
<em:id>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</em:id>
|
||||||
<em:minVersion>10.0</em:minVersion>
|
<em:minVersion>38.0</em:minVersion>
|
||||||
<em:maxVersion>46.0</em:maxVersion>
|
<em:maxVersion>50.0</em:maxVersion>
|
||||||
<!-- Use the raw link for updates so we we can use SSL. -->
|
<!-- Use the raw link for updates so we we can use SSL. -->
|
||||||
<em:updateLink>https://raw.githubusercontent.com/mozilla/pdf.js/gh-pages/extensions/firefox/pdf.js.xpi</em:updateLink>
|
<em:updateLink>https://raw.githubusercontent.com/mozilla/pdf.js/gh-pages/extensions/firefox/pdf.js.xpi</em:updateLink>
|
||||||
</RDF:Description>
|
</RDF:Description>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user