diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-02-13 19:11:37 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-02-13 19:11:37 +0100 |
commit | 43d44975b1f49df640916cca5f6a0b138696da3c (patch) | |
tree | 98b95bb1043fc6a599e3c02fbb9b1ee7a363bf89 /toolkit/components/webextensions/test/mochitest/test_ext_notifications.html | |
parent | 6bb02d95f70000b150569089987701c8244d7d5d (diff) | |
download | UXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar UXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar.gz UXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar.lz UXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar.xz UXP-43d44975b1f49df640916cca5f6a0b138696da3c.zip |
Remove WebExtension support from the platform.
- Conditional code
- WE APIs
- WE toolkit theming
Diffstat (limited to 'toolkit/components/webextensions/test/mochitest/test_ext_notifications.html')
-rw-r--r-- | toolkit/components/webextensions/test/mochitest/test_ext_notifications.html | 224 |
1 files changed, 0 insertions, 224 deletions
diff --git a/toolkit/components/webextensions/test/mochitest/test_ext_notifications.html b/toolkit/components/webextensions/test/mochitest/test_ext_notifications.html deleted file mode 100644 index d1b798cf9..000000000 --- a/toolkit/components/webextensions/test/mochitest/test_ext_notifications.html +++ /dev/null @@ -1,224 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test for notifications</title> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> -</head> -<body> - -<script type="text/javascript"> -"use strict"; - -// A 1x1 PNG image. -// Source: https://commons.wikimedia.org/wiki/File:1x1.png (Public Domain) -let image = atob("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" + - "ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII="); -const IMAGE_ARRAYBUFFER = Uint8Array.from(image, byte => byte.charCodeAt(0)).buffer; - -add_task(function* test_notification() { - async function background() { - let opts = { - type: "basic", - title: "Testing Notification", - message: "Carry on", - }; - - let id = await browser.notifications.create(opts); - - browser.test.sendMessage("running", id); - browser.test.notifyPass("background test passed"); - } - - let extension = ExtensionTestUtils.loadExtension({ - manifest: { - permissions: ["notifications"], - }, - background, - }); - yield extension.startup(); - let x = yield extension.awaitMessage("running"); - is(x, "0", "got correct id from notifications.create"); - yield extension.awaitFinish(); - yield extension.unload(); -}); - -add_task(function* test_notification_events() { - async function background() { - let opts = { - type: "basic", - title: "Testing Notification", - message: "Carry on", - }; - - // Test an ignored listener. - browser.notifications.onButtonClicked.addListener(function() {}); - - // We cannot test onClicked listener without a mock - // but we can attempt to add a listener. - browser.notifications.onClicked.addListener(function() {}); - - // Test onClosed listener. - browser.notifications.onClosed.addListener(id => { - browser.test.sendMessage("closed", id); - browser.test.notifyPass("background test passed"); - }); - - await browser.notifications.create("5", opts); - let id = await browser.notifications.create("5", opts); - browser.test.sendMessage("running", id); - } - - let extension = ExtensionTestUtils.loadExtension({ - manifest: { - permissions: ["notifications"], - }, - background, - }); - yield extension.startup(); - let x = yield extension.awaitMessage("closed"); - is(x, "5", "got correct id from onClosed listener"); - x = yield extension.awaitMessage("running"); - is(x, "5", "got correct id from notifications.create"); - yield extension.awaitFinish(); - yield extension.unload(); -}); - -add_task(function* test_notification_clear() { - async function background() { - let opts = { - type: "basic", - title: "Testing Notification", - message: "Carry on", - }; - - browser.notifications.onClosed.addListener(id => { - browser.test.sendMessage("closed", id); - }); - - let id = await browser.notifications.create("99", opts); - - let wasCleared = await browser.notifications.clear(id); - browser.test.sendMessage("cleared", wasCleared); - - browser.test.notifyPass("background test passed"); - } - - let extension = ExtensionTestUtils.loadExtension({ - manifest: { - permissions: ["notifications"], - }, - background, - }); - yield extension.startup(); - let x = yield extension.awaitMessage("closed"); - is(x, "99", "got correct id from onClosed listener"); - x = yield extension.awaitMessage("cleared"); - is(x, true, "got correct boolean from notifications.clear"); - yield extension.awaitFinish(); - yield extension.unload(); -}); - -add_task(function* test_notifications_empty_getAll() { - async function background() { - let notifications = await browser.notifications.getAll(); - - browser.test.assertEq("object", typeof notifications, "getAll() returned an object"); - browser.test.assertEq(0, Object.keys(notifications).length, "the object has no properties"); - browser.test.notifyPass("getAll empty"); - } - - let extension = ExtensionTestUtils.loadExtension({ - manifest: { - permissions: ["notifications"], - }, - background, - }); - yield extension.startup(); - yield extension.awaitFinish("getAll empty"); - yield extension.unload(); -}); - -add_task(function* test_notifications_populated_getAll() { - async function background() { - let opts = { - type: "basic", - iconUrl: "a.png", - title: "Testing Notification", - message: "Carry on", - }; - - await browser.notifications.create("p1", opts); - await browser.notifications.create("p2", opts); - let notifications = await browser.notifications.getAll(); - - browser.test.assertEq("object", typeof notifications, "getAll() returned an object"); - browser.test.assertEq(2, Object.keys(notifications).length, "the object has 2 properties"); - - for (let notificationId of ["p1", "p2"]) { - for (let key of Object.keys(opts)) { - browser.test.assertEq( - opts[key], - notifications[notificationId][key], - `the notification has the expected value for option: ${key}` - ); - } - } - - browser.test.notifyPass("getAll populated"); - } - - let extension = ExtensionTestUtils.loadExtension({ - manifest: { - permissions: ["notifications"], - }, - background, - files: { - "a.png": IMAGE_ARRAYBUFFER, - }, - }); - yield extension.startup(); - yield extension.awaitFinish("getAll populated"); - yield extension.unload(); -}); - -add_task(function* test_buttons_unsupported() { - function background() { - let opts = { - type: "basic", - title: "Testing Notification", - message: "Carry on", - buttons: [{title: "Button title"}], - }; - - let exception = {}; - try { - browser.notifications.create(opts); - } catch (e) { - exception = e; - } - - browser.test.assertTrue( - String(exception).includes('Property "buttons" is unsupported by Firefox'), - "notifications.create with buttons option threw an expected exception" - ); - browser.test.notifyPass("buttons-unsupported"); - } - - let extension = ExtensionTestUtils.loadExtension({ - manifest: { - permissions: ["notifications"], - }, - background, - }); - yield extension.startup(); - yield extension.awaitFinish("buttons-unsupported"); - yield extension.unload(); -}); - -</script> - -</body> -</html> |