diff options
Diffstat (limited to 'mobile/android/components/extensions/test/mochitest')
7 files changed, 0 insertions, 329 deletions
diff --git a/mobile/android/components/extensions/test/mochitest/.eslintrc.js b/mobile/android/components/extensions/test/mochitest/.eslintrc.js deleted file mode 100644 index 5f9059e18..000000000 --- a/mobile/android/components/extensions/test/mochitest/.eslintrc.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; - -module.exports = { - "extends": "../../../../../../toolkit/components/extensions/test/mochitest/.eslintrc.js", - - "globals": { - "isPageActionShown": true, - "clickPageAction": true, - }, -}; diff --git a/mobile/android/components/extensions/test/mochitest/chrome.ini b/mobile/android/components/extensions/test/mochitest/chrome.ini deleted file mode 100644 index e19ddf393..000000000 --- a/mobile/android/components/extensions/test/mochitest/chrome.ini +++ /dev/null @@ -1,7 +0,0 @@ -[DEFAULT] -support-files = - head.js -tags = webextensions - -[test_ext_pageAction.html] -[test_ext_pageAction_popup.html] diff --git a/mobile/android/components/extensions/test/mochitest/head.js b/mobile/android/components/extensions/test/mochitest/head.js deleted file mode 100644 index be9683682..000000000 --- a/mobile/android/components/extensions/test/mochitest/head.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -/* exported isPageActionShown clickPageAction */ - -const {classes: Cc, interfaces: Ci, utils: Cu} = Components; - -Cu.import("resource://gre/modules/PageActions.jsm"); - -function isPageActionShown(uuid) { - return PageActions.isShown(uuid); -} - -function clickPageAction(uuid) { - PageActions.synthesizeClick(uuid); -} diff --git a/mobile/android/components/extensions/test/mochitest/mochitest.ini b/mobile/android/components/extensions/test/mochitest/mochitest.ini deleted file mode 100644 index 59ef4bd20..000000000 --- a/mobile/android/components/extensions/test/mochitest/mochitest.ini +++ /dev/null @@ -1,6 +0,0 @@ -[DEFAULT] -support-files = - ../../../../../../toolkit/components/extensions/test/mochitest/test_ext_all_apis.js -tags = webextensions - -[test_ext_all_apis.html] diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html b/mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html deleted file mode 100644 index aec3eb7c1..000000000 --- a/mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html +++ /dev/null @@ -1,23 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>WebExtension test</title> - <meta charset="utf-8"> - <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> -"use strict"; -/* exported expectedContentApisTargetSpecific, expectedBackgroundApisTargetSpecific */ -let expectedContentApisTargetSpecific = [ -]; - -let expectedBackgroundApisTargetSpecific = [ -]; -</script> -<script src="test_ext_all_apis.js"></script> -</body> -</html> diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_pageAction.html b/mobile/android/components/extensions/test/mochitest/test_ext_pageAction.html deleted file mode 100644 index b13c551bd..000000000 --- a/mobile/android/components/extensions/test/mochitest/test_ext_pageAction.html +++ /dev/null @@ -1,99 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>PageAction Test</title> - <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> - <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> - <script type="text/javascript" src="head.js"></script> - <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> -</head> -<body> - -<script type="text/javascript"> -"use strict"; - -let dataURI = "iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAC4klEQVRYhdWXLWzbQBSADQtDAwsHC1tUhUxqfL67lk2tdn+OJg0ODU0rLByqgqINBY6tmlbn7LMTJ5FaFVVBk1G0oUGjG2jT2Y7jxmmcbU/6iJ+f36fz+e5sGP9riCGm9hB37RG+scd4Yo/wsDXCZyIE2xuXsce4bY+wXkAsQtzYmExrfFgvkJkRbkzo1ehoxx5iXcgI/9iYUGt8WH9MqDXEcmNChmEYrRCf2SHWeYgQx3x0tLNRIeKQLTtEFyJEep4NTuhk8BC+yMrwEE3+iozo42d8gK7FAOkMsRiiN8QhW2ttSK5QTfRRV4QoymVeJMvPvDp7gCZigD613MN6yRFA3SWarow9QB9LCfG+NeF9qCtjAKOSQjCqVKhfVsiHEQ+grgx/lRGqUihAc1uL8EFD+KCRO+GrF4J61phcoRoPoEzkYhZYpykh5sMb7kOdIeY+jHKur4QI4Feh4AFX1nVeLxrAvQchGsBz5ls6wa2QdwcvIcE2863bTH79KOvsz/uUYJsp+J0pSzNlDckVqqVGUAF+n6uS7txcOl6wot4JVy70ufDLy4pWLUQVPE81pRI0mGe9oxLMHSeohHvMs/STUNaUK6vDPCvOyxMFDx4achehRDJmHnydnkPww5OFfLxrGIZBFDyYl4LpMzlTQFIP6AQx86w2UeYBccFpJrcKv5L9eGDtUAU6RIELqsB74uynjy/UBRF1gS5BTFxwQT1wTiXoUg9MH7m/3NZRRoi5IJytUbMgzv4Wc832+oQkiKgEehmyMkkpKsFkQV11QsRJL5rJYBLItQgRaUZEmnoZXsomz3vGiWw+I9KMF9SVFOqZEemZekli1jN3U/UOqhHHvC6oWWGElhfSpGdOk6+O9prdwvtLj5BjRsQxdRnot+Zeifpy/2/0stktKTRNLmbk0mwXyl8253fyojj+8rxOHNAhjjm5n0/5OOCGOKBzkrMO0Z75lvSAzKlrF32Z/3z8BqLAn+yMV7VhAAAAAElFTkSuQmCC"; - -let image = atob(dataURI); -const IMAGE_ARRAYBUFFER = Uint8Array.from(image, byte => byte.charCodeAt(0)).buffer; - -function background() { - browser.test.assertTrue("pageAction" in browser, "Namespace 'pageAction' exists in browser"); - browser.test.assertTrue("show" in browser.pageAction, "API method 'show' exists in browser.pageAction"); - - // TODO: Use the Tabs API to obtain the tab ids for showing pageActions. - let tabId = 1; - browser.test.onMessage.addListener(msg => { - if (msg === "pageAction-show") { - browser.pageAction.show(tabId).then(() => { - browser.test.sendMessage("page-action-shown"); - }); - } else if (msg === "pageAction-hide") { - browser.pageAction.hide(tabId).then(() => { - browser.test.sendMessage("page-action-hidden"); - }); - } - }); - - browser.pageAction.onClicked.addListener(tab => { - // TODO: Make sure we get the correct tab once basic tabs support is added. - browser.test.sendMessage("page-action-clicked"); - }); - - let extensionInfo = { - // Extract the assigned uuid from the background page url. - uuid: `{${window.location.hostname}}`, - }; - - browser.test.sendMessage("ready", extensionInfo); -} - -add_task(function* test_pageAction() { - let extension = ExtensionTestUtils.loadExtension({ - background, - manifest: { - "name": "PageAction Extension", - "page_action": { - "default_title": "Page Action", - "default_icon": { - "18": "extension.png", - }, - }, - "applications": { - "gecko": { - "id": "foo@bar.com", - }, - }, - }, - files: { - "extension.png": IMAGE_ARRAYBUFFER, - }, - }); - - yield extension.startup(); - let {uuid} = yield extension.awaitMessage("ready"); - - extension.sendMessage("pageAction-show"); - yield extension.awaitMessage("page-action-shown"); - ok(isPageActionShown(uuid), "The PageAction should be shown"); - - extension.sendMessage("pageAction-hide"); - yield extension.awaitMessage("page-action-hidden"); - ok(!isPageActionShown(uuid), "The PageAction should be hidden"); - - extension.sendMessage("pageAction-show"); - yield extension.awaitMessage("page-action-shown"); - ok(isPageActionShown(uuid), "The PageAction should be shown"); - - clickPageAction(uuid); - yield extension.awaitMessage("page-action-clicked"); - ok(isPageActionShown(uuid), "The PageAction should still be shown after being clicked"); - - yield extension.unload(); - ok(!isPageActionShown(uuid), "The PageAction should be removed after unload"); -}); -</script> - -</body> -</html> diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_popup.html b/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_popup.html deleted file mode 100644 index 89edc7c29..000000000 --- a/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_popup.html +++ /dev/null @@ -1,169 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>PageAction Test</title> - <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> - <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script> - <script type="text/javascript" src="head.js"></script> - <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> -</head> -<body> - -<script type="text/javascript"> -"use strict"; - -Cu.import("resource://gre/modules/Services.jsm"); - -let dataURI = "iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAC4klEQVRYhdWXLWzbQBSADQtDAwsHC1tUhUxqfL67lk2tdn+OJg0ODU0rLByqgqINBY6tmlbn7LMTJ5FaFVVBk1G0oUGjG2jT2Y7jxmmcbU/6iJ+f36fz+e5sGP9riCGm9hB37RG+scd4Yo/wsDXCZyIE2xuXsce4bY+wXkAsQtzYmExrfFgvkJkRbkzo1ehoxx5iXcgI/9iYUGt8WH9MqDXEcmNChmEYrRCf2SHWeYgQx3x0tLNRIeKQLTtEFyJEep4NTuhk8BC+yMrwEE3+iozo42d8gK7FAOkMsRiiN8QhW2ttSK5QTfRRV4QoymVeJMvPvDp7gCZigD613MN6yRFA3SWarow9QB9LCfG+NeF9qCtjAKOSQjCqVKhfVsiHEQ+grgx/lRGqUihAc1uL8EFD+KCRO+GrF4J61phcoRoPoEzkYhZYpykh5sMb7kOdIeY+jHKur4QI4Feh4AFX1nVeLxrAvQchGsBz5ls6wa2QdwcvIcE2863bTH79KOvsz/uUYJsp+J0pSzNlDckVqqVGUAF+n6uS7txcOl6wot4JVy70ufDLy4pWLUQVPE81pRI0mGe9oxLMHSeohHvMs/STUNaUK6vDPCvOyxMFDx4achehRDJmHnydnkPww5OFfLxrGIZBFDyYl4LpMzlTQFIP6AQx86w2UeYBccFpJrcKv5L9eGDtUAU6RIELqsB74uynjy/UBRF1gS5BTFxwQT1wTiXoUg9MH7m/3NZRRoi5IJytUbMgzv4Wc832+oQkiKgEehmyMkkpKsFkQV11QsRJL5rJYBLItQgRaUZEmnoZXsomz3vGiWw+I9KMF9SVFOqZEemZekli1jN3U/UOqhHHvC6oWWGElhfSpGdOk6+O9prdwvtLj5BjRsQxdRnot+Zeifpy/2/0stktKTRNLmbk0mwXyl8253fyojj+8rxOHNAhjjm5n0/5OOCGOKBzkrMO0Z75lvSAzKlrF32Z/3z8BqLAn+yMV7VhAAAAAElFTkSuQmCC"; - -let image = atob(dataURI); -const IMAGE_ARRAYBUFFER = Uint8Array.from(image, byte => byte.charCodeAt(0)).buffer; - -add_task(function* test_contentscript() { - function background() { - // TODO: Use the Tabs API to obtain the tab ids for showing pageActions. - let tabId = 1; - let onClickedListenerEnabled = false; - - browser.test.onMessage.addListener((msg, details) => { - if (msg === "page-action-show") { - // TODO: switch to using .show(tabId).then(...) once bug 1270742 lands. - browser.pageAction.show(tabId).then(() => { - browser.test.sendMessage("page-action-shown"); - }); - } else if (msg == "page-action-set-popup") { - browser.pageAction.setPopup({popup: details.name, tabId: tabId}).then(() => { - browser.test.sendMessage("page-action-popup-set"); - }); - } else if (msg == "page-action-get-popup") { - browser.pageAction.getPopup({tabId: tabId}).then(url => { - browser.test.sendMessage("page-action-got-popup", url); - }); - } else if (msg == "page-action-enable-onClicked-listener") { - onClickedListenerEnabled = true; - browser.test.sendMessage("page-action-onClicked-listener-enabled"); - } else if (msg == "page-action-disable-onClicked-listener") { - onClickedListenerEnabled = false; - browser.test.sendMessage("page-action-onClicked-listener-disabled"); - } - }); - - browser.pageAction.onClicked.addListener(tab => { - browser.test.assertTrue(onClickedListenerEnabled, "The onClicked listener should only fire when it is enabled."); - browser.test.sendMessage("page-action-onClicked-fired"); - }); - - let extensionInfo = { - // Extract the assigned uuid from the background page url. - uuid: `{${window.location.hostname}}`, - }; - - browser.test.sendMessage("ready", extensionInfo); - } - - function popupScript() { - window.onload = () => { - browser.test.sendMessage("page-action-from-popup", location.href); - }; - browser.test.onMessage.addListener((msg, details) => { - if (msg == "page-action-close-popup") { - if (details.location == location.href) { - window.close(); - } - } - }); - } - - let extension = ExtensionTestUtils.loadExtension({ - background, - manifest: { - "name": "PageAction Extension", - "page_action": { - "default_title": "Page Action", - "default_popup": "default.html", - "default_icon": { - "18": "extension.png", - }, - }, - }, - files: { - "default.html": `<html><head><meta charset="utf-8"><script src="popup.js"><\/script></head></html>`, - "extension.png": IMAGE_ARRAYBUFFER, - "a.html": `<html><head><meta charset="utf-8"><script src="popup.js"><\/script></head></html>`, - "b.html": `<html><head><meta charset="utf-8"><script src="popup.js"><\/script></head></html>`, - "popup.js": popupScript, - }, - }); - - let tabClosedPromise = () => { - return new Promise(resolve => { - let chromeWin = Services.wm.getMostRecentWindow("navigator:browser"); - let BrowserApp = chromeWin.BrowserApp; - - let tabCloseListener = (event) => { - BrowserApp.deck.removeEventListener("TabClose", tabCloseListener, false); - let browser = event.target; - let url = browser.currentURI.spec; - resolve(url); - }; - - BrowserApp.deck.addEventListener("TabClose", tabCloseListener, false); - }); - }; - - function* testPopup(name, uuid) { - // We don't need to set the popup when testing default_popup. - if (name != "default.html") { - extension.sendMessage("page-action-set-popup", {name}); - yield extension.awaitMessage("page-action-popup-set"); - } - - extension.sendMessage("page-action-get-popup"); - let url = yield extension.awaitMessage("page-action-got-popup"); - - if (name == "") { - ok(url == name, "Calling pageAction.getPopup should return an empty string when the popup is not set."); - - // The onClicked listener should get called when the popup is set to an empty string. - extension.sendMessage("page-action-enable-onClicked-listener"); - yield extension.awaitMessage("page-action-onClicked-listener-enabled"); - - clickPageAction(uuid); - yield extension.awaitMessage("page-action-onClicked-fired"); - - extension.sendMessage("page-action-disable-onClicked-listener"); - yield extension.awaitMessage("page-action-onClicked-listener-disabled"); - } else { - ok(url.includes(name), "Calling pageAction.getPopup should return the correct popup URL when the popup is set."); - - clickPageAction(uuid); - let location = yield extension.awaitMessage("page-action-from-popup"); - ok(location.includes(name), "The popup with the correct URL should be shown."); - - extension.sendMessage("page-action-close-popup", {location}); - - url = yield tabClosedPromise(); - ok(url.includes(name), "The tab for the popup should be closed."); - } - } - - yield extension.startup(); - let {uuid} = yield extension.awaitMessage("ready"); - - extension.sendMessage("page-action-show"); - yield extension.awaitMessage("page-action-shown"); - ok(isPageActionShown(uuid), "The PageAction should be shown."); - - yield testPopup("default.html", uuid); - yield testPopup("a.html", uuid); - yield testPopup("", uuid); - yield testPopup("b.html", uuid); - - yield extension.unload(); - ok(!isPageActionShown(uuid), "The PageAction should be removed after unload."); -}); -</script> - -</body> -</html> |