Add testing override preferences handling for slumber start and end days
This commit is contained in:
Родитель
d37e6e9cec
Коммит
2d901fae8c
|
@ -7,6 +7,9 @@ src/feature.js
|
|||
src/privileged/privacyContext/api.js
|
||||
src/privileged/privacyContext/schema.json
|
||||
src/privileged/privacyContext/stubApi.js
|
||||
src/privileged/testingOverrides/api.js
|
||||
src/privileged/testingOverrides/schema.json
|
||||
src/privileged/testingOverrides/stubApi.js
|
||||
# do not lint/format bundled util libraries
|
||||
src/privileged/study/api.js
|
||||
src/privileged/study/schema.json
|
||||
|
|
|
@ -88,9 +88,13 @@
|
|||
"format": "prettier '**/*.{css,js,ts,json,jsm,md}' --trailing-comma=all --ignore-path=.eslintignore --write",
|
||||
"generate": "npm-run-all -s -n generate:generateSchema:* generate:verifyWeeSchema:* generate:documentSchema:* generate:generateStubApi:*",
|
||||
"generate:documentSchema:privacyContext": "cd src/privileged/privacyContext && documentSchema schema.json > api.md",
|
||||
"generate:documentSchema:testingOverrides": "cd src/privileged/testingOverrides && documentSchema schema.json > api.md",
|
||||
"generate:generateSchema:privacyContext": "cd src/privileged/privacyContext && yaml2json schema.yaml -p > schema.json",
|
||||
"generate:generateSchema:testingOverrides": "cd src/privileged/testingOverrides && yaml2json schema.yaml -p > schema.json",
|
||||
"generate:generateStubApi:privacyContext": "cd src/privileged/privacyContext && generateStubApi ./schema.json > stubApi.js",
|
||||
"generate:generateStubApi:testingOverrides": "cd src/privileged/testingOverrides && generateStubApi ./schema.json > stubApi.js",
|
||||
"generate:verifyWeeSchema:privacyContext": "cd src/privileged/privacyContext && verifyWeeSchema schema.json",
|
||||
"generate:verifyWeeSchema:testingOverrides": "cd src/privileged/testingOverrides && verifyWeeSchema schema.json",
|
||||
"harness_test": "npm run test:func -- --retry 2 --reporter json",
|
||||
"lint": "npm-run-all lint:*",
|
||||
"lint:eslint": "npm run eslint",
|
||||
|
|
|
@ -26,6 +26,14 @@
|
|||
"script": "./privileged/study/api.js",
|
||||
"paths": [["study"]]
|
||||
}
|
||||
},
|
||||
"testingOverrides": {
|
||||
"schema": "./privileged/testingOverrides/schema.json",
|
||||
"parent": {
|
||||
"scopes": ["addon_parent"],
|
||||
"script": "./privileged/testingOverrides/api.js",
|
||||
"paths": [["testingOverrides"]]
|
||||
}
|
||||
}
|
||||
},
|
||||
"background": {
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/* global ExtensionAPI */
|
||||
|
||||
"use strict";
|
||||
|
||||
this.testingOverrides = class extends ExtensionAPI {
|
||||
getAPI(context) {
|
||||
const { Preferences } = ChromeUtils.import(
|
||||
"resource://gre/modules/Preferences.jsm",
|
||||
{},
|
||||
);
|
||||
|
||||
const { extension } = this;
|
||||
|
||||
// Copied here from tree
|
||||
function makeWidgetId(id) {
|
||||
id = id.toLowerCase();
|
||||
return id.replace(/[^a-z0-9_-]/g, "_");
|
||||
}
|
||||
|
||||
const widgetId = makeWidgetId(extension.manifest.applications.gecko.id);
|
||||
|
||||
return {
|
||||
testingOverrides: {
|
||||
getSlumberStartDayOverride: async function getSlumberStartDayOverride() {
|
||||
return Preferences.get(
|
||||
`extensions.${widgetId}.test.slumberStartDayOverride`,
|
||||
false,
|
||||
);
|
||||
},
|
||||
getSlumberEndDayOverride: async function getSlumberEndDayOverride() {
|
||||
return Preferences.get(
|
||||
`extensions.${widgetId}.test.slumberEndDayOverride`,
|
||||
false,
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
# Namespace: `browser.testingOverrides`
|
||||
|
||||
Accesses additional preferences used for study testing
|
||||
|
||||
## Functions
|
||||
|
||||
### `browser.testingOverrides.getSlumberStartDayOverride( )`
|
||||
|
||||
**Parameters**
|
||||
|
||||
### `browser.testingOverrides.getSlumberEndDayOverride( )`
|
||||
|
||||
**Parameters**
|
||||
|
||||
## Events
|
||||
|
||||
(None)
|
||||
|
||||
## Properties TBD
|
||||
|
||||
## Data Types
|
||||
|
||||
(None)
|
|
@ -0,0 +1,22 @@
|
|||
[
|
||||
{
|
||||
"namespace": "testingOverrides",
|
||||
"description": "Accesses additional preferences used for study testing",
|
||||
"functions": [
|
||||
{
|
||||
"name": "getSlumberStartDayOverride",
|
||||
"type": "function",
|
||||
"async": true,
|
||||
"description": "",
|
||||
"parameters": []
|
||||
},
|
||||
{
|
||||
"name": "getSlumberEndDayOverride",
|
||||
"type": "function",
|
||||
"async": true,
|
||||
"description": "",
|
||||
"parameters": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,14 @@
|
|||
- namespace: testingOverrides
|
||||
description: Accesses additional preferences used for study testing
|
||||
|
||||
functions:
|
||||
- name: getSlumberStartDayOverride
|
||||
type: 'function'
|
||||
async: true
|
||||
description: ''
|
||||
parameters: []
|
||||
- name: getSlumberEndDayOverride
|
||||
type: 'function'
|
||||
async: true
|
||||
description: ''
|
||||
parameters: []
|
|
@ -0,0 +1,36 @@
|
|||
/* eslint-env commonjs */
|
||||
/* eslint no-logger: off */
|
||||
/* eslint no-unused-vars: off */
|
||||
/* global ExtensionAPI */
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/ExtensionCommon.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/ExtensionUtils.jsm");
|
||||
|
||||
/* eslint-disable no-undef */
|
||||
const { EventManager } = ExtensionCommon;
|
||||
const EventEmitter =
|
||||
ExtensionCommon.EventEmitter || ExtensionUtils.EventEmitter;
|
||||
|
||||
this.testingOverrides = class extends ExtensionAPI {
|
||||
getAPI(context) {
|
||||
const apiEventEmitter = new EventEmitter();
|
||||
return {
|
||||
testingOverrides: {
|
||||
|
||||
/* @TODO no description given */
|
||||
getSlumberStartDayOverride: async function getSlumberStartDayOverride ( ) {
|
||||
console.log("Called getSlumberStartDayOverride()", );
|
||||
return undefined;
|
||||
},
|
||||
|
||||
/* @TODO no description given */
|
||||
getSlumberEndDayOverride: async function getSlumberEndDayOverride ( ) {
|
||||
console.log("Called getSlumberEndDayOverride()", );
|
||||
return undefined;
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
|
@ -184,12 +184,17 @@ async function getStudySetup() {
|
|||
);
|
||||
studySetup.telemetry.removeTestingFlag = false;
|
||||
}
|
||||
|
||||
// Set testing flag on shield-study-addon pings in case the model url endpoint is overridden for testing purposes
|
||||
const modelUrlEndPointOverride = await browser.testingOverrides.getModelUrlEndpointOverride();
|
||||
if (modelUrlEndPointOverride !== "") {
|
||||
const slumberStartDayOverride = await browser.testingOverrides.getSlumberStartDayOverride();
|
||||
if (slumberStartDayOverride !== false) {
|
||||
await browser.study.logger.log(
|
||||
`Note: The model url endpoint is overridden for testing purposes ("${modelUrlEndPointOverride}")`,
|
||||
`Note: The slumber start day is overridden for testing purposes ("${slumberStartDayOverride}")`,
|
||||
);
|
||||
studySetup.telemetry.removeTestingFlag = false;
|
||||
}
|
||||
const slumberEndDayOverride = await browser.testingOverrides.getSlumberEndDayOverride();
|
||||
if (slumberEndDayOverride !== false) {
|
||||
await browser.study.logger.log(
|
||||
`Note: The slumber end day is overridden for testing purposes ("${slumberEndDayOverride}")`,
|
||||
);
|
||||
studySetup.telemetry.removeTestingFlag = false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче