From 600cd3718563b26050b4e89ed5d2feb5723685bb Mon Sep 17 00:00:00 2001 From: ketmar Date: Wed, 22 Aug 2018 06:14:58 +0000 Subject: [PATCH] more pm28 fixes FossilOrigin-Name: e7d5321d5d21995d1a561f7fe893f34654f63ee60d86f9cc365c86940151d0cd --- chrome/guerilla-pkgman.js | 6 +++--- main/modules/injector.js | 2 +- main/modules/sbapi/sandbox.js | 10 +++++----- main/modules/sbapi/xmlhttprequest.js | 28 +++++++++++++++++++++++++++- main/modules/scriptcache.js | 2 +- main/modules/utils/matchpattern.js | 6 +++--- main/modules/utils/metaparser.js | 6 +++--- main/startup.js | 2 +- 8 files changed, 44 insertions(+), 18 deletions(-) diff --git a/chrome/guerilla-pkgman.js b/chrome/guerilla-pkgman.js index 375e562..b40baf9 100644 --- a/chrome/guerilla-pkgman.js +++ b/chrome/guerilla-pkgman.js @@ -8,11 +8,11 @@ * http://www.wtfpl.net/txt/copying/ for more details. */ //////////////////////////////////////////////////////////////////////////////// -const {utils:Cu, classes:Cc, interfaces:Ci, results:Cr} = Components; -const addonobj = Cu.import("chrome://guerilla-script-jscode/content/startup.js").getAddonObj(); +let {utils:Cu, classes:Cc, interfaces:Ci, results:Cr} = Components; +let addonobj = Cu.import("chrome://guerilla-script-jscode/content/startup.js").getAddonObj(); addonobj.sbox.debuglog("GS pkgman window!"); -const uiMain = addonobj.sbox.require("mainjs:ui/pkgman.js"); +let uiMain = addonobj.sbox.require("mainjs:ui/pkgman.js"); uiMain.newWindow(window); diff --git a/main/modules/injector.js b/main/modules/injector.js index a2f212a..3aa589e 100644 --- a/main/modules/injector.js +++ b/main/modules/injector.js @@ -30,7 +30,7 @@ uses("resource://gre/modules/XPCOMUtils.jsm"); let {closeStorageObjects, createSandbox, runInSandbox} = require("sbapi/sandbox"); -const stripCredsRE = new RegExp("(://)([^:/]+)(:[^@/]+)?@"); +let stripCredsRE = new RegExp("(://)([^:/]+)(:[^@/]+)?@"); //const conService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService); //function logStr (str) conService.logStringMessage(str); diff --git a/main/modules/sbapi/sandbox.js b/main/modules/sbapi/sandbox.js index 6c3f3f1..900ea34 100644 --- a/main/modules/sbapi/sandbox.js +++ b/main/modules/sbapi/sandbox.js @@ -26,10 +26,10 @@ * copies or substantial portions of the Software. */ //////////////////////////////////////////////////////////////////////////////// -const {GuerillaXmlHttpReqester} = require("sbapi/xmlhttprequest"); -const {ScriptStorage} = require("sbapi/scriptstorage"); -const {openTab} = require("sbapi/opentab"); -const {buildRelFile} = require("scriptcache"); +let {GuerillaXmlHttpReqester} = require("sbapi/xmlhttprequest"); +let {ScriptStorage} = require("sbapi/scriptstorage"); +let {openTab} = require("sbapi/opentab"); +let {buildRelFile} = require("scriptcache"); //////////////////////////////////////////////////////////////////////////////// @@ -62,7 +62,7 @@ function uriFromUrl (url, base) { } -const newFileURI = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService).newFileURI; +let newFileURI = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService).newFileURI; //////////////////////////////////////////////////////////////////////////////// diff --git a/main/modules/sbapi/xmlhttprequest.js b/main/modules/sbapi/xmlhttprequest.js index 3e9f50c..2834e63 100644 --- a/main/modules/sbapi/xmlhttprequest.js +++ b/main/modules/sbapi/xmlhttprequest.js @@ -118,6 +118,8 @@ GuerillaXmlHttpReqester.prototype.contentStartRequest = function (details) { readyState: "r", responseHeaders: "r", responseText: "r", + responseXML: "rw", + responseJSON: "rw", status: "r", statusText: "r", byteLength: "r" @@ -127,6 +129,8 @@ GuerillaXmlHttpReqester.prototype.contentStartRequest = function (details) { readyState: null, responseHeaders: null, responseText: null, + responseXML: null, + responseJSON: null, status: null, statusText: null, byteLength: null @@ -142,6 +146,16 @@ GuerillaXmlHttpReqester.prototype.contentStartRequest = function (details) { // some response types don't have .responseText (but do have e.g. blob.response): ignore } try { + rv.responseXML = req.responseXML; + } catch (e) { + // some response types don't have .responseText (but do have e.g. blob.response): ignore + } + try { + rv.responseJSON = req.responseJSON; + } catch (e) { + // some response types don't have .responseText (but do have e.g. blob.response): ignore + } + try { rv.byteLength = req.byteLength; } catch (e) {} rv.status = req.status; @@ -267,8 +281,9 @@ GuerillaXmlHttpReqester.prototype.setupRequestEvent = function (wrappedContentWi readyState: "r", response: "r", responseHeaders: "r", - responseText: "r", + responseText: "rw", responseXML: "rw", + responseJSON: "rw", status: "r", statusText: "r", total: "r", @@ -283,6 +298,7 @@ GuerillaXmlHttpReqester.prototype.setupRequestEvent = function (wrappedContentWi responseHeaders: null, responseText: null, responseXML: null, + responseJSON: null, status: null, statusText: null, total: null, @@ -314,6 +330,16 @@ GuerillaXmlHttpReqester.prototype.setupRequestEvent = function (wrappedContentWi responseState.responseXML = ""; } + let responseJSON = null; + try { + responseJSON = req.responseJSON; + } catch (e) { + // ignore failure; at least in responseType blob case, this access fails + } + if (responseJSON) { + responseState.responseJSON = Cu.cloneInto(responseJSON, sandbox); + } + switch (event) { case "progress": responseState.lengthComputable = evt.lengthComputable; diff --git a/main/modules/scriptcache.js b/main/modules/scriptcache.js index 6977356..043885c 100644 --- a/main/modules/scriptcache.js +++ b/main/modules/scriptcache.js @@ -62,7 +62,7 @@ exports.buildRelFile = buildRelFile; //////////////////////////////////////////////////////////////////////////////// -const nameExtRE = /^(.+)(\.[^.]+)$/; +let nameExtRE = /^(.+)(\.[^.]+)$/; //////////////////////////////////////////////////////////////////////////////// diff --git a/main/modules/utils/matchpattern.js b/main/modules/utils/matchpattern.js index caf0139..03d0882 100644 --- a/main/modules/utils/matchpattern.js +++ b/main/modules/utils/matchpattern.js @@ -38,10 +38,10 @@ * * ***** END LICENSE BLOCK ***** */ //////////////////////////////////////////////////////////////////////////////// -const validSchemes = ["http", "https", "ftp", "file"]; -const REG_HOST = /^(?:\*\.)?[^*\/]+$|^\*$|^$/; +let validSchemes = ["http", "https", "ftp", "file"]; +let REG_HOST = /^(?:\*\.)?[^*\/]+$|^\*$|^$/; -const iosvc = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); +let iosvc = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); //////////////////////////////////////////////////////////////////////////////// diff --git a/main/modules/utils/metaparser.js b/main/modules/utils/metaparser.js index ab35cc7..1e8777a 100644 --- a/main/modules/utils/metaparser.js +++ b/main/modules/utils/metaparser.js @@ -8,9 +8,9 @@ * http://www.wtfpl.net/txt/copying/ for more details. */ //////////////////////////////////////////////////////////////////////////////// -const wholeMetaRE = /^\s*\/\/\s*==UserScript==\s*([\s\S]*?)^\/\/\s*==\/UserScript==/m; -const metakvRE = /^\s*@(\S+)\s+(.+?)\s*$/; -const metakeyRE = /^\s*@(\S+)\s*$/; +let wholeMetaRE = /^\s*\/\/\s*==UserScript==\s*([\s\S]*?)^\/\/\s*==\/UserScript==/m; +let metakvRE = /^\s*@(\S+)\s+(.+?)\s*$/; +let metakeyRE = /^\s*@(\S+)\s*$/; // return array of {name, value} objects; value can be null diff --git a/main/startup.js b/main/startup.js index c362619..d7b6c6c 100644 --- a/main/startup.js +++ b/main/startup.js @@ -10,7 +10,7 @@ //////////////////////////////////////////////////////////////////////////////// this.EXPORTED_SYMBOLS = []; -const {utils:Cu, classes:Cc, interfaces:Ci, results:Cr} = Components; +let {utils:Cu, classes:Cc, interfaces:Ci, results:Cr} = Components; //////////////////////////////////////////////////////////////////////////////// -- 2.11.4.GIT