diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /mobile/android/components/extensions/test/mochitest/test_ext_pageAction.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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 'mobile/android/components/extensions/test/mochitest/test_ext_pageAction.html')
-rw-r--r-- | mobile/android/components/extensions/test/mochitest/test_ext_pageAction.html | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_pageAction.html b/mobile/android/components/extensions/test/mochitest/test_ext_pageAction.html new file mode 100644 index 000000000..b13c551bd --- /dev/null +++ b/mobile/android/components/extensions/test/mochitest/test_ext_pageAction.html @@ -0,0 +1,99 @@ +<!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> |