From 5b753dc1467714c8b315e118b1202a1b51026ff9 Mon Sep 17 00:00:00 2001 From: groovecoder Date: Thu, 15 Dec 2016 16:27:05 -0600 Subject: [PATCH] initial commit --- .eslintrc.js | 4 +++ .gitignore | 2 ++ README.md | 53 ++++++++++++++++++++++++++++++-- index.js | 16 ++++++++++ package.json | 30 ++++++++++++++++++ test/test-index.js | 19 ++++++++++++ webextension/img/icon-50x50.png | Bin 0 -> 1296 bytes webextension/js/popup.js | 5 +++ webextension/manifest.json | 36 ++++++++++++++++++++++ webextension/popup.html | 17 ++++++++++ 10 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 .eslintrc.js create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package.json create mode 100644 test/test-index.js create mode 100644 webextension/img/icon-50x50.png create mode 100644 webextension/js/popup.js create mode 100644 webextension/manifest.json create mode 100644 webextension/popup.html diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..6fef2cd --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + "extends": "nightmare-mode", + "installedESLint": true +}; diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c0a6319 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +README.html +*.xpi diff --git a/README.md b/README.md index 842932e..abaf4f0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,52 @@ -# Test Pilot Containers +# Containers: Test Pilot Experiment +## AKA ?? -This repo is the home of a *Containers*-based experiment to be launched in [Firefox Test Pilot](https://github.com/mozilla/testpilot). +[![Available on Test Pilot](https://img.shields.io/badge/available_on-Test_Pilot-0996F8.svg)](https://testpilot.firefox.com/) + +[Embedded Web Extension](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Embedded_WebExtensions) to experiment with [Containers](https://blog.mozilla.org/tanvi/2016/06/16/contextual-identities-on-the-web/) in [Firefox Test Pilot](https://testpilot.firefox.com/) to learn: + +* Will a general Firefox audience understand the Containers feature? +* Is the UI as currently implemented in Nightly clear or discoverable? + +See [the Product Hypothesis Document for more +details](https://docs.google.com/document/d/1WQdHTVXROk7dYkSFluc6_hS44tqZjIrG9I-uPyzevE8/edit?ts=5824ba12#). + + +## Requirements + +* Firefox 50+ + + +## Run it + +See Development + + +## Development +### Development Environment + +Add-on development is better with [a particular environment](https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment). One simple way to get that environment set up is to install the [DevPrefs add-on](https://addons.mozilla.org/en-US/firefox/addon/devprefs/). You can make a custom Firefox profile that includes the DevPrefs add-on, and use that profile when you run the code in this repository. + +1. Make a new profile by running `/path/to/firefox -P`, which launches the profile editor. "Create Profile" -- name it whatever you wish (e.g. 'addon_dev') and store it in the default location. It's probably best to deselect the option to "Use without asking," since you probably don't want to use this as your default profile. + +2. Once you've created your profile, click "Start Firefox". A new instance of Firefox should launch. Go to Tools->Add-ons and search for "DevPrefs". Install it. Quit Firefox. + +3. Now you have a new, vanilla Firefox profile with the DevPrefs add-on installed. You can use your new profile with the code in _this_ repository like so: + + +### Run with jpm + +1. Clone this repo locally +2. `cd testpilot-containers` +3. `npm install` +4. `./node_modules/.bin/jpm run -p /Path/To/Firefox/Profiles/{junk}.addon_dev -b FirefoxDeveloperEdition` + +Check out the [Browser Toolbox](https://developer.mozilla.org/en-US/docs/Tools/Browser_Toolbox) for more information about debugging add-on code. + + +### Testing +TBD + + +### Distributing +TBD diff --git a/index.js b/index.js new file mode 100644 index 0000000..cc7c0e5 --- /dev/null +++ b/index.js @@ -0,0 +1,16 @@ +const webExtension = require('sdk/webextension'); + +function handleWebExtensionMessage(message, sender, sendReply) { + console.log(message); + if (message === 'message-from-webextension') { + sendReply({ + content: 'reply-from-sdk' + }); + } +} + +webExtension.startup().then(api=> { + const {browser} = api; + + browser.runtime.onMessage.addListener(handleWebExtensionMessage); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..c85dc13 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "title": "Containers Experiment", + + "name": "testpilot-containers", + + "version": "0.0.1", + + "description": "Containers works by isolating cookie jars using separate origin-attributes defined visually by colored ‘Container Tabs’. This add-on is a modified version of the containers feature for Firefox Test Pilot.", + + "main": "index.js", + + "author": "Luke Crouch & Jonathan Kingston", + + "engines": { + "firefox": ">=50.0" + }, + + "license": "MPL2", + + "keywords": [ + "jetpack" + ], + + "hasEmbeddedWebExtension": true, + + "devDependencies": { + "jpm": "^1.2.2", + "eslint": "^3.12.2" + } +} diff --git a/test/test-index.js b/test/test-index.js new file mode 100644 index 0000000..b3ad6e8 --- /dev/null +++ b/test/test-index.js @@ -0,0 +1,19 @@ +var main = require("../"); + +exports["test main"] = function(assert) { + assert.pass("Unit test running!"); +}; + +exports["test main async"] = function(assert, done) { + assert.pass("async Unit test running!"); + done(); +}; + +exports["test dummy"] = function(assert, done) { + main.dummy("foo", function(text) { + assert.ok((text === "foo"), "Is the text actually 'foo'"); + done(); + }); +}; + +require("sdk/test").run(exports); diff --git a/webextension/img/icon-50x50.png b/webextension/img/icon-50x50.png new file mode 100644 index 0000000000000000000000000000000000000000..f357d62c858e13ef75c1c65cc5fb89aaa3e84ab5 GIT binary patch literal 1296 zcmV+r1@HQaP)(^xB>_oNB=7(L1hq*-K~!i3?U~0;Bry<%Ysfh#fyg2wkaz+l z&b$LBUXMrMj6g_mA?GA=&T09)*y?TEJw46zE<2i%MxE@c`dzN%i9J6*ze@^GMhak1 z5VD*=-rs*4M_--ag51YqF*QtIgUmq|zqhwH$;ikM<|Z;<%lHEbFJE3>FH^inVFG?hX?n# zz|R2b>FJUB`g*CVsuHZ^M@L6TGCMmf>+9?C^ze9vh;jDC#YNfN-24^@6u!K? z6nL>!f-K16jZJx5IC2Y{>llyz&jQdPhgcmlcN(AX`4R7WJ5oA_aoL zf`S5RY;2T@iVCYm0JglmEVs9}Qdn51%9Ej?p)a}u2CHH*8$}L;LNY%;U;S(fIICT@ z4$n0;HMXI??@}fqrh)j{`5$~V7NH69%9@Glg=4}mUM~V)q7mbmgFl7o4&h^*9S5td ztP~O#VKNM%42wa8Dl04Vj4)2#M5@}_TGfk??1)TZ$N(7_7*L4`5Qm3{D&D(eemnt$ z#)gIlA$+2oSEzLIp&J|-8IgsB1=Z#@H#a*!2fmMeD6Se2>Y$5@3!x0qnKm$&&w*?c zLM_(d7i60tm%|R~t>WThH9yFfbn9j;!eq=$8BKBuLjWNGq7e5GR>jJCft+Q#TLueg zBY08fkomDPTi8to2<0?AJBI-HNf^Qc_*q+9o3ysJD&g>@JXu;=lB=t$xP_xlE`0Hw zzP>)Sb!~oRfUK^r%H-svI?=E(3;K?gqa+z0A6FTgT54iqLRGY3gNT;Bv$G?^!^1K- zIH+Hls{z8GlamwkA?ytY82B3f2mV4swYRrt?L`umfsS6g#Q?!Cy!L1!0<}-jTL224 zVNWjIa?#Q2h{+^GoG{UF>lWmEh8K;LpL09M2f6pt(Etg;=qHa!1NmvzNn0dsk%(3x zy|p4**wAd#774v{5lu`zi`bf#?=BuZlgZbQm$3*PVvyD}2si}7OY`(oAP7G_2A*Cz z8X)|gOe^_aLU}qkPGx9$IRfS2*-L>$&_@S68cMC=mgAEWI^HLA1K? z;b@3ckS!=c==#s|!N_;q(LxAed(q zr?H~DquKfn5L##sNNij64 literal 0 HcmV?d00001 diff --git a/webextension/js/popup.js b/webextension/js/popup.js new file mode 100644 index 0000000..fd8006b --- /dev/null +++ b/webextension/js/popup.js @@ -0,0 +1,5 @@ +browser.runtime.sendMessage('message-from-webextension').then(reply=> { + if (reply) { + console.log('response from sdk addon: ', reply.content); + } +}); diff --git a/webextension/manifest.json b/webextension/manifest.json new file mode 100644 index 0000000..3eaede1 --- /dev/null +++ b/webextension/manifest.json @@ -0,0 +1,36 @@ +{ + "manifest_version": 2, + "name": "Containers Experiment", + "version": "0.0.1", + + "description": "Containers works by isolating cookie jars using separate origin-attributes defined visually by colored ‘Container Tabs’. This add-on is a modified version of the containers feature for Firefox Test Pilot.", + "icons": { + "48": "img/blok-48.png", + "96": "img/blok-96.png" + }, + + "applications": { + "gecko": { + "id": "testpilot-containers@mozilla.org", + "strict_min_version": "50.0", + "update_url": "https://testpilot.firefox.com/files/containers/updates.json" + } + }, + + "homepage_url": "https://testpilot.firefox.com/", + + "permissions": [ + ], + + "browser_action": { + "browser_style": true, + "default_icon": { + "16": "img/icon-50x50.png", + "32": "img/icon-50x50.png" + }, + "default_title": "Containers", + "default_popup": "popup.html" + } + +} + diff --git a/webextension/popup.html b/webextension/popup.html new file mode 100644 index 0000000..25f2f16 --- /dev/null +++ b/webextension/popup.html @@ -0,0 +1,17 @@ + + + + Containers browserAction Popup + + +

Containers!

+ +

Edit Containers

+ + +