Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*xpi
5 changes: 5 additions & 0 deletions code/.jpmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.*
node_modules
!/node_modules/shield-studies-addon-utils
!/lib
!/test
2 changes: 2 additions & 0 deletions code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#My Jetpack Addon
A basic add-on
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
this.EXPORTED_SYMBOLS = [
"BrowserListener",
];
const {Ci, Cu, Cc} = require("chrome");

const STYLE_URL = "chrome://unified-urlbar/content/style.css";
const STYLE_URL = require("sdk/self").data.url("style.css");
const SEARCH_BAR_WIDGET_ID = "search-container";
const XHTML_NS = "http://www.w3.org/1999/xhtml";

const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/CustomizableUI.jsm");
Cu.import("chrome://unified-urlbar/content/Panel.jsm");

const { Panel } = require("./Panel.js");

var gBranch = "control";
var gBrowsers = null;
Expand Down Expand Up @@ -151,3 +149,6 @@ function whenWindowLoaded(win, callback) {
}
}, true);
}

// require-ify
exports.BrowserListener = BrowserListener;
9 changes: 4 additions & 5 deletions code/content/Panel.jsm → code/content/Panel.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
this.EXPORTED_SYMBOLS = [
"Panel",
];
const {Ci, Cu, Cc} = require("chrome");

const EXISTING_FOOTER_ID = "urlbar-search-footer";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("chrome://unified-urlbar/content/Telemetry.jsm");
const { Telemetry } = require("./Telemetry");

this.Panel = function (panelElt) {
this.panelElement = panelElt;
Expand Down Expand Up @@ -536,3 +533,5 @@ this.Panel.prototype = {
this._selectedButton = null;
},
};

exports.Panel = Panel;
9 changes: 5 additions & 4 deletions code/content/Telemetry.jsm → code/content/Telemetry.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
this.EXPORTED_SYMBOLS = [
"Telemetry",
];
const {Ci, Cu, Cc} = require("chrome");

const SEARCH_SUGGESTIONS_OPT_IN_CHOICE_PREF =
"browser.urlbar.userMadeSearchSuggestionsChoice";

const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource:///modules/BrowserUITelemetry.jsm");
Expand Down Expand Up @@ -135,3 +132,7 @@ function addSearchSuggestionsOptInTelemetry() {
let optedIn = Preferences.get("browser.urlbar.suggest.searches");
Telemetry.setValue("suggestionsEnabled", optedIn);
}


exports.Telemetry = Telemetry;

File renamed without changes
4 changes: 2 additions & 2 deletions code/content/style.css → code/data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@
}

#urlbar-search-settings2 {
list-style-image: url("chrome://unified-urlbar/content/gear.svg#gear");
list-style-image: url("./gear.svg#gear");
background-position: left center;
border-bottom: none;
}

#urlbar-search-settings2:hover {
list-style-image: url("chrome://unified-urlbar/content/gear.svg#gear-inverted");
list-style-image: url("./gear.svg#gear-inverted");
background-color: Highlight;
}

Expand Down
51 changes: 51 additions & 0 deletions code/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//BUG: Call ryanvm to get person to test addon

/* 1. the modules needed to turn this into a STUDY */
const xutils = require("shield-studies-addon-utils");
const variationsMod = require("./variations");

const addonPrefs = require("sdk/simple-prefs").prefs;

/* 2. configuration / setup constants for the study.
* These are only ones needed, or supported
*/
const forSetup = {
name: "Unified Urlbar Shield Study 1", // unique for Telemetry
choices: Object.keys(variationsMod.variations), // names of branches.
duration: 7, // in days,
/* Get surveyUrl from Strategy + Insights */
surveyUrl: "https://qsurvey.mozilla.com/s3/Shield-Study-Example-Survey"
};

// 3. Study Object (module singleton);
var ourConfig = xutils.xsetup(forSetup);
let thisStudy = new xutils.Study(ourConfig,variationsMod);

// 3a (optional). Watch for changes and reporting
xutils.Reporter.on("report",(d)=>console.debug("telemetry", d));
thisStudy.on("change",(newState)=>console.debug("newState:", newState));

/* 4. usual bootstrap / jetpack main function */
function main (options, callback) {
// TURN ON TELEMETRY, using an indirect pref!!!
xutils.generateTelemetryIdIfNeeded().then(function () {
xutils.handleStartup(options, thisStudy);
})
// addon specific load code should go here, if there is additional.
console.debug(`special addon loading code: ${options.loadReason}`)
console.debug(JSON.stringify(addonPrefs, null, 2))
}

function onUnload (reason) {
console.debug(`special addon unloading code: ${reason}`)
xutils.handleOnUnload(reason, thisStudy);

// special unload code, specific to addon if any.
console.debug(`special addon unloading code: ${reason}`)
console.debug(JSON.stringify(addonPrefs, null, 2))
}


/* 5. usual bootstrap addon exports */
exports.main = main;
exports.onUnload = onUnload
8 changes: 4 additions & 4 deletions code/install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>[email protected]</em:id>
<em:id>unified-urlbar-shield-study-1@experiments.mozilla.org</em:id>
<em:version>1.0.0</em:version>
<em:type>128</em:type>
<em:type>2</em:type>
<em:bootstrap>true</em:bootstrap>
<em:unpack>false</em:unpack>

Expand All @@ -13,11 +13,11 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>43.0</em:minVersion>
<em:maxVersion>47.0</em:maxVersion>
<em:maxVersion>49.0</em:maxVersion>
</Description>
</em:targetApplication>

<em:name>Unified Urlbar Experiment</em:name>
<em:name>Unified Urlbar Experiment Shield Study</em:name>
<em:description>
An experimental add-on testing the unified urlbar experience.
</em:description>
Expand Down
21 changes: 21 additions & 0 deletions code/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"title": "X-Unified-Urlbar-Study",
"name": "code",
"version": "0.0.1",
"description": "A basic add-on",
"main": "index.js",
"author": "",
"engines": {
"firefox": ">=38.0a1",
"fennec": ">=38.0a1"
},
"license": "MIT",
"keywords": [
"jetpack"
],
"devDependencies": {
"chai": "^3.5.0",
"jpm": "^1.0.7",
"shield-studies-addon-utils": "^1.0.1"
}
}
19 changes: 19 additions & 0 deletions code/test/test-index.js
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);
104 changes: 104 additions & 0 deletions code/variations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// facade for enumerated urlbar variations

const { BrowserListener } = require("./content/BrowserListener");
const { Telemetry } = require("./content/Telemetry");

/* Telemetry Pref needs to be on to record searches */
const TEL_PREF = "toolkit.telemetry.enabled";
const SUGGEST_PREF = "browser.urlbar.suggest.searches";

let prefSvc = require("sdk/preferences/service");
let prefs = require("sdk/simple-prefs").prefs;

// BUG, are these robust *enough*? Generalize to prefs in general.
function setShadowPref (name, value) {
let shadow = name + ".shadow";
if (!prefSvc.isSet(shadow)) {
let original = prefSvc.get(name);
prefSvc.set(shadow, original);
prefSvc.set(name, value);
}
}

function resetShadowPref (name) {
let shadow = name + ".shadow";
if (prefSvc.isSet(shadow)) {
let original = prefSvc.get(shadow);
prefSvc.set(name, original);
prefSvc.reset(shadow);
}
}

// BUG: should control arm arm turn on suggestions?
// BUG: should having suggestions on include/exclude?

/* create a safe, multi-callable, idempotent modification */
let isCalled = false;
function modify (branch) {
if (!isCalled) {
setShadowPref(TEL_PREF, true);
setShadowPref(SUGGEST_PREF, true);
isCalled = true;
BrowserListener.init(branch);
Telemetry.init(branch);
}
};


let variations = {
"unified": () => modify("unified"),
//- modify placement
//- Orientation note (onboarding) (BUG!)

"control": () => modify("control")
//"customized": // trash this from the study
};

function isEligible () {
/* BUG
eligible: {
is not customized the search bar already.
AND version < 50
}*/
return true;
};

function cleanup () {
resetTelemetry();
BrowserListener.destroy();
Telemetry.destroy();
return true;
};


module.exports = {
isEligible: isEligible,
cleanup: cleanup,
variations: variations,
};


/* TODO: tests
- after destroy...
- telemetry is reset
- searchbar is back

*/
/*

everyoneSetup :
- force extended telemetry on
- onboarding check or show
- turn on seach suggestions
`browser.urlbar.suggest.searches` ??


cleanup:
# restore telemetry from indirect pref
# `browser.urlbar.suggest.searches` ??

# remove indirect pref
# searchbar restore? "placement"
BrowserListener.destroy();
Telemetry.destroy();
*/
5 changes: 5 additions & 0 deletions code/x-prefs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extensions.unified-urlbar-shield-study-1@experiments.mozilla.org.variation": "unified",
"extensions.sdk.console.logLevel": "debug",
"general.warnOnAboutConfig": false
}