Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
Changed webextension api namespace from shieldUtils to study
Browse files Browse the repository at this point in the history
  • Loading branch information
motin committed Apr 2, 2018
1 parent bc03d74 commit 0a8a43b
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions examples/test-addon/bin/bundle-shield-studies-addon-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ set -o errexit
script_path=`dirname $0`
cd "$script_path/../../"

# bundle the shieldUtils web extension experiment
mkdir -p test-addon/src/privileged/shieldUtils
cp webExtensionApis/shieldUtils/api.js test-addon/src/privileged/shieldUtils/api.js
cp webExtensionApis/shieldUtils/schema.json test-addon/src/privileged/shieldUtils/schema.json
# bundle the study web extension experiment
mkdir -p test-addon/src/privileged/study
cp webExtensionApis/study/api.js test-addon/src/privileged/study/api.js
cp webExtensionApis/study/schema.json test-addon/src/privileged/study/schema.json

# bundle the prefs web extension experiment
mkdir -p test-addon/src/privileged/prefs
Expand Down
6 changes: 3 additions & 3 deletions examples/test-addon/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ async function initiateStudy() {
// Set dynamic study configuration flags
studySetup.eligible = await Study.isEligible();
studySetup.expired = await Study.hasExpired();
// Ensure we have configured shieldUtils and are supposed to run our feature
await browser.shieldUtils.bootstrapStudy(studySetup);
// Ensure we have configured study and are supposed to run our feature
await browser.study.bootstrapStudy(studySetup);
// Get study variation
const { variation } = await browser.shieldUtils.info();
const { variation } = await browser.study.info();
// Initiate the study
new Study(variation);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/test-addon/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"paths": [["prefs"]]
}
},
"shieldUtils": {
"schema": "./privileged/shieldUtils/schema.json",
"study": {
"schema": "./privileged/study/schema.json",
"parent": {
"scopes": ["addon_parent"],
"script": "./privileged/shieldUtils/api.js",
"paths": [["shieldUtils"]]
"script": "./privileged/study/api.js",
"paths": [["study"]]
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion examples/test-addon/src/privileged/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# ignore APIs that are bundled from shield-studies-addon-utils
shieldUtils/
study/
prefs/
4 changes: 2 additions & 2 deletions examples/test-addon/test/functional/shield_utils_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ describe("Shield Study Add-on Utils Functional Tests", function() {
assert(hasAccessToWebExtensionApi);
});

it("should be able to access shieldUtils WebExtensions API from the extension page for tests", async () => {
it("should be able to access study WebExtensions API from the extension page for tests", async () => {
const hasAccessToShieldUtilsWebExtensionApi = await utils.executeJs.executeAsyncScriptInExtensionPageForTests(
driver,
async callback => {
callback(browser && typeof browser.shieldUtils === "object");
callback(browser && typeof browser.study === "object");
},
);
assert(hasAccessToShieldUtilsWebExtensionApi);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"url": "git://github.com/mozilla/shield-studies-addon-utils.git"
},
"scripts": {
"build": "cd webExtensionApis/shieldUtils && webpack",
"build": "cd webExtensionApis/study && webpack",
"docformat": "doctoc --title '**Contents**' docs/*.md && prettier '**/*.md' --write",
"eslint": "eslint src --ext jsm --ext js --ext json",
"eslint-fix": "npm run eslint -- --fix",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"namespace": "shieldUtils",
"description": "shieldUtils",
"namespace": "study",
"description": "study",
"functions": [
{
"name": "bootstrapStudy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* global ExtensionAPI */

this.shieldUtils = class extends ExtensionAPI {
this.study = class extends ExtensionAPI {
/**
* We don't need to override the constructor for other
* reasons than to clarify the class member "extension"
Expand Down Expand Up @@ -39,9 +39,9 @@ this.shieldUtils = class extends ExtensionAPI {
const { extension } = this;

return {
shieldUtils: {
study: {
/**
* ensure we have configured shieldUtils
* ensure we have configured study
* and are supposed to run our feature
* @returns {Promise<void>}
*/
Expand Down

0 comments on commit 0a8a43b

Please sign in to comment.