@ -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 ) ;
}
}