summaryrefslogtreecommitdiffstats
path: root/dom/manifest/test/browser_fire_appinstalled_event.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 /dom/manifest/test/browser_fire_appinstalled_event.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 'dom/manifest/test/browser_fire_appinstalled_event.js')
-rw-r--r--dom/manifest/test/browser_fire_appinstalled_event.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/dom/manifest/test/browser_fire_appinstalled_event.js b/dom/manifest/test/browser_fire_appinstalled_event.js
new file mode 100644
index 000000000..517b120d3
--- /dev/null
+++ b/dom/manifest/test/browser_fire_appinstalled_event.js
@@ -0,0 +1,49 @@
+//Used by JSHint:
+/*global Cu, BrowserTestUtils, ok, add_task, gBrowser */
+"use strict";
+const { PromiseMessage } = Cu.import("resource://gre/modules/PromiseMessage.jsm", {});
+const testPath = "/browser/dom/manifest/test/file_reg_appinstalled_event.html";
+const defaultURL = new URL("http://example.org/browser/dom/manifest/test/file_testserver.sjs");
+const testURL = new URL(defaultURL);
+testURL.searchParams.append("file", testPath);
+
+// Enable window.onappinstalled, so we can fire events at it.
+function enableOnAppInstalledPref() {
+ const ops = {
+ "set": [
+ ["dom.manifest.onappinstalled", true],
+ ],
+ };
+ return SpecialPowers.pushPrefEnv(ops);
+}
+
+// Send a message for the even to be fired.
+// This cause file_reg_install_event.html to be dynamically change.
+function* theTest(aBrowser) {
+ aBrowser.allowEvents = true;
+ let waitForInstall = ContentTask.spawn(aBrowser, null, function*() {
+ yield ContentTaskUtils.waitForEvent(content.window, "appinstalled");
+ });
+ const { data: { success } } = yield PromiseMessage
+ .send(aBrowser.messageManager, "DOM:Manifest:FireAppInstalledEvent");
+ ok(success, "message sent and received successfully.");
+ try {
+ yield waitForInstall;
+ ok(true, "AppInstalled event fired");
+ } catch (err) {
+ ok(false, "AppInstalled event didn't fire: " + err.message);
+ }
+}
+
+// Open a tab and run the test
+add_task(function*() {
+ yield enableOnAppInstalledPref();
+ let tabOptions = {
+ gBrowser: gBrowser,
+ url: testURL.href,
+ };
+ yield BrowserTestUtils.withNewTab(
+ tabOptions,
+ theTest
+ );
+});