summaryrefslogtreecommitdiffstats
path: root/docshell/test/browser/file_bug422543_script.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /docshell/test/browser/file_bug422543_script.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'docshell/test/browser/file_bug422543_script.js')
-rw-r--r--docshell/test/browser/file_bug422543_script.js98
1 files changed, 98 insertions, 0 deletions
diff --git a/docshell/test/browser/file_bug422543_script.js b/docshell/test/browser/file_bug422543_script.js
new file mode 100644
index 000000000..cd69df1ec
--- /dev/null
+++ b/docshell/test/browser/file_bug422543_script.js
@@ -0,0 +1,98 @@
+const { utils: Cu, interfaces: Ci } = Components;
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+function SHistoryListener() {
+}
+
+SHistoryListener.prototype = {
+ retval: true,
+ last: "initial",
+
+ OnHistoryNewEntry: function (aNewURI) {
+ this.last = "newentry";
+ },
+
+ OnHistoryGoBack: function (aBackURI) {
+ this.last = "goback";
+ return this.retval;
+ },
+
+ OnHistoryGoForward: function (aForwardURI) {
+ this.last = "goforward";
+ return this.retval;
+ },
+
+ OnHistoryGotoIndex: function (aIndex, aGotoURI) {
+ this.last = "gotoindex";
+ return this.retval;
+ },
+
+ OnHistoryPurge: function (aNumEntries) {
+ this.last = "purge";
+ return this.retval;
+ },
+
+ OnHistoryReload: function (aReloadURI, aReloadFlags) {
+ this.last = "reload";
+ return this.retval;
+ },
+
+ OnHistoryReplaceEntry: function (aIndex) {},
+
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsISHistoryListener,
+ Ci.nsISupportsWeakReference])
+};
+
+let testAPI = {
+ shistory: null,
+ listeners: [ new SHistoryListener(),
+ new SHistoryListener() ],
+
+ init() {
+ this.shistory = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
+ for (let listener of this.listeners) {
+ this.shistory.addSHistoryListener(listener);
+ }
+ },
+
+ cleanup() {
+ for (let listener of this.listeners) {
+ this.shistory.removeSHistoryListener(listener);
+ }
+ this.shistory = null;
+ sendAsyncMessage("bug422543:cleanup:return", {});
+ },
+
+ getListenerStatus() {
+ sendAsyncMessage("bug422543:getListenerStatus:return",
+ this.listeners.map(l => l.last));
+ },
+
+ resetListeners() {
+ for (let listener of this.listeners) {
+ listener.last = "initial";
+ }
+
+ sendAsyncMessage("bug422543:resetListeners:return", {});
+ },
+
+ notifyReload() {
+ let internal = this.shistory.QueryInterface(Ci.nsISHistoryInternal);
+ let rval =
+ internal.notifyOnHistoryReload(content.document.documentURIObject, 0);
+ sendAsyncMessage("bug422543:notifyReload:return", { rval });
+ },
+
+ setRetval({ num, val }) {
+ this.listeners[num].retval = val;
+ sendAsyncMessage("bug422543:setRetval:return", {});
+ },
+};
+
+addMessageListener("bug422543:cleanup", () => { testAPI.cleanup(); });
+addMessageListener("bug422543:getListenerStatus", () => { testAPI.getListenerStatus(); });
+addMessageListener("bug422543:notifyReload", () => { testAPI.notifyReload(); });
+addMessageListener("bug422543:resetListeners", () => { testAPI.resetListeners(); });
+addMessageListener("bug422543:setRetval", (msg) => { testAPI.setRetval(msg.data); });
+
+testAPI.init();