fx-compat: Load zotero://report/ channels as chrome
It seems that the issue wasn't that zotero:// URLs can't be loaded in a content browser, but rather that the report extension was returning a channel that the content browser couldn't access. For some reason, it handled that failure by passing the URL off to the OS, which then opened a duplicate instance of Zotero. Also: - Remove ensureBrowserType() and always use <browser type="content"> in basicViewer (see b8966f) - Fix system principal being used to load extensions without `loadAsChrome` set to true if an extension with `loadAsChrome` set to true had been loaded in the past
This commit is contained in:
parent
6a85dd2c5e
commit
48f7830558
2 changed files with 10 additions and 41 deletions
|
@ -31,7 +31,10 @@ var browser;
|
|||
|
||||
window.addEventListener("load", /*async */function () {
|
||||
browser = document.querySelector('browser');
|
||||
ensureBrowserType('content');
|
||||
|
||||
browser.addEventListener('pagetitlechanged', () => {
|
||||
document.title = browser.contentTitle || browser.currentURI.spec;
|
||||
});
|
||||
|
||||
/*
|
||||
browser.setAttribute("remote", "true");
|
||||
|
@ -69,41 +72,8 @@ window.addEventListener("click", function (event) {
|
|||
}
|
||||
});
|
||||
|
||||
function ensureBrowserType(type) {
|
||||
let oldBrowser = browser;
|
||||
if (!oldBrowser || oldBrowser.getAttribute('type') != type) {
|
||||
browser = document.createXULElement('browser');
|
||||
let attrs = {
|
||||
type,
|
||||
flex: 1,
|
||||
remote: false,
|
||||
maychangeremoteness: true,
|
||||
disableglobalhistory: true,
|
||||
};
|
||||
for (let [attr, value] of Object.entries(attrs)) {
|
||||
browser.setAttribute(attr, value);
|
||||
}
|
||||
if (oldBrowser) {
|
||||
oldBrowser.replaceWith(browser);
|
||||
}
|
||||
else {
|
||||
document.querySelector('#appcontent').append(browser);
|
||||
}
|
||||
browser.addEventListener('pagetitlechanged', () => {
|
||||
document.title = browser.contentTitle || browser.currentURI.spec;
|
||||
});
|
||||
return browser;
|
||||
}
|
||||
else {
|
||||
return oldBrowser;
|
||||
}
|
||||
}
|
||||
|
||||
function loadURI(uri) {
|
||||
// The zotero protocol handler will not load in a type="content" browser
|
||||
// As a temporary fix, replace the browser with one of the correct type if necessary
|
||||
// (The type attribute can't be changed after the browser is created)
|
||||
ensureBrowserType(uri.startsWith('zotero:') ? 'chrome' : 'content').loadURI(
|
||||
browser.loadURI(
|
||||
uri,
|
||||
{
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
|
|
|
@ -156,7 +156,7 @@ function ZoteroProtocolHandler() {
|
|||
* Report generation extension for Zotero protocol
|
||||
*/
|
||||
var ReportExtension = {
|
||||
loadAsChrome: false,
|
||||
loadAsChrome: true,
|
||||
|
||||
newChannel: function (uri, loadInfo) {
|
||||
return new AsyncChannel(uri, loadInfo, function* () {
|
||||
|
@ -1293,10 +1293,6 @@ ZoteroProtocolHandler.prototype = {
|
|||
return this._getCancelledChannel();
|
||||
}
|
||||
|
||||
if (!this._principal && ext.loadAsChrome) {
|
||||
this._principal = Services.scriptSecurityManager.getSystemPrincipal();
|
||||
}
|
||||
|
||||
var extChannel = ext.newChannel(uri, loadInfo);
|
||||
// Extension returned null, so cancel request
|
||||
if (!extChannel) {
|
||||
|
@ -1304,7 +1300,10 @@ ZoteroProtocolHandler.prototype = {
|
|||
}
|
||||
|
||||
// Apply cached principal to extension channel
|
||||
if (this._principal) {
|
||||
if (ext.loadAsChrome) {
|
||||
if (!this._principal) {
|
||||
this._principal = Services.scriptSecurityManager.getSystemPrincipal();
|
||||
}
|
||||
extChannel.owner = this._principal;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue