forked from mozilla/testpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build a wrapper for submitExternalPing()
- Add small example add-on showing how to use the ping messaging - Switch to sdk/system/events for cleaner access to nsIObserver - Remove lib/authRequest.js for now, because metrics pings do not go to the Test Pilot server any more. (Feedback also now does nothing) - Do not ping for every message that the addon sends to web content - Small bugfix for isTestpilotAddonID - Misc reorganizing in require()'s at the top Issue mozilla#479
Showing
12 changed files
with
185 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#Test Pilot Example Experiment 1 | ||
A basic add-on |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- | ||
* This Source Code is subject to the terms of the Mozilla Public License | ||
* version 2.0 (the 'License'). You can obtain a copy of the License at | ||
* http://mozilla.org/MPL/2.0/. | ||
--> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="stylesheet" href="panel.css" type="text/css" media="screen" /> | ||
</head> | ||
<body> | ||
<p>These buttons send metric pings!</p> | ||
<ul class="pings"> | ||
<li><button id="b1">One</button></li> | ||
<li><button id="b2">Two</button></li> | ||
<li><button id="b3">Three</button></li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function $$ (selector, el) { | ||
return Array.prototype.slice.call((el || document) | ||
.querySelectorAll(selector)); | ||
} | ||
|
||
$$('.pings li button').forEach(function (el) { | ||
el.addEventListener('click', function (ev) { | ||
self.port.emit('buttonClicked', el.id); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const self = require("sdk/self"); | ||
|
||
const {ToggleButton} = require('sdk/ui/button/toggle'); | ||
const {Panel} = require('sdk/panel'); | ||
const Events = require("sdk/system/events"); | ||
|
||
// TODO: Move this into a shared library? | ||
function sendMetricsPing(self, payload) { | ||
Events.emit('testpilot::send-metric', { | ||
subject: self.id, | ||
data: JSON.stringify(payload) | ||
}); | ||
} | ||
|
||
let panel, button; | ||
|
||
exports.main = function (options, callbacks) { | ||
|
||
panel = Panel({ // eslint-disable-line new-cap | ||
contentURL: './panel.html', | ||
contentScriptFile: './panel.js', | ||
onHide: () => { | ||
button.state('window', {checked: false}); | ||
} | ||
}); | ||
|
||
panel.port.on('buttonClicked', function (buttonID) { | ||
sendMetricsPing(self, { | ||
happening: 'buttonClicked', | ||
buttonID: buttonID | ||
}); | ||
}); | ||
|
||
button = ToggleButton({ // eslint-disable-line new-cap | ||
id: "experiment-1-link", | ||
label: "Experiment 1", | ||
icon: { | ||
"16": "./icon-16.png", | ||
"32": "./icon-32.png", | ||
"64": "./icon-64.png" | ||
}, | ||
onChange: (state) => { | ||
|
||
sendMetricsPing(self, { | ||
happening: 'buttonStateChange', | ||
currentState: state.checked | ||
}); | ||
|
||
if (!state.checked) { return; } | ||
|
||
panel.show({ | ||
width: 200, | ||
height: 200, | ||
position: button | ||
}); | ||
|
||
} | ||
}); | ||
|
||
}; | ||
|
||
exports.onUnload = function (reason) { | ||
panel.destroy(); | ||
button.destroy(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"title": "Test Pilot Example Experiment 1", | ||
"name": "testpilot-addon-sdk-example-experiment", | ||
"version": "0.0.1", | ||
"description": "A basic add-on", | ||
"main": "index.js", | ||
"author": "Mozilla (https://mozilla.org/)", | ||
"engines": { | ||
"firefox": ">=38.0a1" | ||
}, | ||
"keywords": [ | ||
"jetpack" | ||
], | ||
"scripts": { | ||
"start": "npm run watch", | ||
"once": "jpm run -b beta", | ||
"watch": "jpm watchpost --post-url http://localhost:8888", | ||
"lint": "eslint ." | ||
}, | ||
"license": "MPL-2.0", | ||
"devDependencies": { | ||
"babel-eslint": "4.1.8", | ||
"eslint": "^1.10.3", | ||
"eslint-config-airbnb": "^0.0.8", | ||
"jpm": "1.0.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |