From da9154d8114590db0226374ae6a2066513d769a5 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 13 May 2022 03:49:23 -0400 Subject: [PATCH] fx-compat: Get basicViewer working for debug output Doesn't work with, e.g., zotero://timeline/library --- chrome/content/zotero/fileInterface.js | 2 +- .../content/zotero/preferences/preferences.js | 2 +- .../content/zotero/standalone/basicViewer.js | 46 +++++++++++++------ .../{basicViewer.xul => basicViewer.xhtml} | 35 ++++++++++---- chrome/content/zotero/xpcom/zotero.js | 2 +- 5 files changed, 59 insertions(+), 28 deletions(-) rename chrome/content/zotero/standalone/{basicViewer.xul => basicViewer.xhtml} (84%) diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js index 5b7bf81274..6bab8f9caa 100644 --- a/chrome/content/zotero/fileInterface.js +++ b/chrome/content/zotero/fileInterface.js @@ -1017,7 +1017,7 @@ var Zotero_File_Interface = new function() { const arg = Components.classes["@mozilla.org/supports-string;1"] .createInstance(Components.interfaces.nsISupportsString); arg.data = uri; - win = ww.openWindow(null, "chrome://zotero/content/standalone/basicViewer.xul", + win = ww.openWindow(null, "chrome://zotero/content/standalone/basicViewer.xhtml", "basicViewer", "chrome,dialog=yes,resizable,centerscreen,menubar,scrollbars", arg); } diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js index d66793ab06..1aebb6db1d 100644 --- a/chrome/content/zotero/preferences/preferences.js +++ b/chrome/content/zotero/preferences/preferences.js @@ -141,7 +141,7 @@ var Zotero_Preferences = { if(win) { win.loadURI(uri); } else { - window.openDialog("chrome://zotero/content/standalone/basicViewer.xul", + window.openDialog("chrome://zotero/content/standalone/basicViewer.xhtml", "basicViewer", "chrome,resizable,centerscreen,menubar,scrollbars", uri); } } else { diff --git a/chrome/content/zotero/standalone/basicViewer.js b/chrome/content/zotero/standalone/basicViewer.js index f3ff1cdcf4..e0381f3a9d 100644 --- a/chrome/content/zotero/standalone/basicViewer.js +++ b/chrome/content/zotero/standalone/basicViewer.js @@ -23,28 +23,44 @@ ***** END LICENSE BLOCK ***** */ -var browser; -function loadURI() { - browser.loadURI.apply(browser, arguments); -} +/*const { E10SUtils } = ChromeUtils.import( + "resource://gre/modules/E10SUtils.jsm" +);*/ -window.addEventListener("load", function() { - browser = document.getElementById('my-browser'); +var browser; + +window.addEventListener("load", /*async */function() { + browser = document.querySelector('browser'); + + /* + browser.setAttribute("remote", "true"); + //browser.setAttribute("remoteType", E10SUtils.EXTENSION_REMOTE_TYPE); + + await new Promise((resolve) => { + browser.addEventListener("XULFrameLoaderCreated", () => resolve()); + }); + */ + + /*browser.messageManager.loadFrameScript( + 'chrome://zotero/content/standalone/basicViewerContent.js', + false + );*/ + //browser.docShellIsActive = false; // align page title with title of shown document browser.addEventListener("pageshow", function() { - document.title = (browser.contentDocument.title - ? browser.contentDocument.title - : browser.contentDocument.location.href); + document.title = browser.contentDocument.title || browser.contentDocument.location.href; }, false); - // show document - browser.loadURI.apply(browser, window.arguments); + // Load URI passed in as nsISupports .data via openWindow() + browser.loadURI( + window.arguments[0], + { + triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), + //loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_STOP_CONTENT, + } + ); - // XXX Why is this necessary to make the scroll bars appear? - window.setTimeout(function() { - document.getElementById("my-browser").style.overflow = "auto"; - }, 0); }, false); window.addEventListener("keypress", function (event) { diff --git a/chrome/content/zotero/standalone/basicViewer.xul b/chrome/content/zotero/standalone/basicViewer.xhtml similarity index 84% rename from chrome/content/zotero/standalone/basicViewer.xul rename to chrome/content/zotero/standalone/basicViewer.xhtml index 91b458aa83..df48975e6b 100644 --- a/chrome/content/zotero/standalone/basicViewer.xul +++ b/chrome/content/zotero/standalone/basicViewer.xhtml @@ -33,7 +33,7 @@ %globalDTD; - %textcontextDTD; + %standaloneDTD; %brandDTD; %zoteroDTD; @@ -46,12 +46,23 @@ title="&brandShortName;" width="1000" height="700" persist="screenX screenY width height sizemode"> - @@ -73,7 +84,7 @@ - + - + diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 6ec0593023..be41816dff 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1109,7 +1109,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); let arg = Components.classes["@mozilla.org/supports-string;1"] .createInstance(Components.interfaces.nsISupportsString); arg.data = uri; - win = ww.openWindow(null, "chrome://zotero/content/standalone/basicViewer.xul", + win = ww.openWindow(null, "chrome://zotero/content/standalone/basicViewer.xhtml", "basicViewer", "chrome,dialog=yes,resizable,centerscreen,menubar,scrollbars", arg); } if (onLoad) {