This repository was archived by the owner on Mar 17, 2023. It is now read-only.
generated from mozilla-rally/study-template
-
Notifications
You must be signed in to change notification settings - Fork 3
[DO NOT MERGE] Comments on the current implementation #14
Open
jonathanmayer
wants to merge
513
commits into
comments
Choose a base branch
from
main
base: comments
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 38 commits
Commits
Show all changes
513 commits
Select commit
Hold shift + click to select a range
f40d3f0
Merge pull request #122 from mozilla-rally/dependabot/npm_and_yarn/es…
7258bf4
Merge pull request #155 from mozilla-rally/dependabot/npm_and_yarn/es…
064200b
Merge pull request #169 from mozilla-rally/dependabot/npm_and_yarn/ro…
874d8b7
Bump @rollup/plugin-replace from 2.4.2 to 3.0.0
dependabot[bot] 090ed92
Merge pull request #168 from mozilla-rally/dependabot/npm_and_yarn/ro…
86a6cec
Bump @rollup/plugin-commonjs from 19.0.0 to 20.0.0
dependabot[bot] 98d30d4
Bump @mozilla/rally from 0.6.0 to 0.7.0
dependabot[bot] 008b780
Bump web-ext from 6.1.0 to 6.4.0
dependabot[bot] 032b5a2
Merge pull request #171 from mozilla-rally/dependabot/npm_and_yarn/ro…
3ee9be9
Merge pull request #172 from mozilla-rally/dependabot/npm_and_yarn/we…
dfb5f3a
Merge pull request #173 from mozilla-rally/dependabot/npm_and_yarn/mo…
90c05b8
Bump selenium-webdriver from 4.0.0-beta.3 to 4.0.0-rc-1
dependabot[bot] a24fa4a
upgrade to latest rally-sdk
rhelmer 054ba92
prefer target name style test:integration over test-integration
rhelmer f4a24c6
need to build before lint, to ensure content scripts from dependencie…
rhelmer 92e1f38
provide working examples for local emulators and rally-web-spike site
rhelmer c1d3b82
rebuild package-lock after rebase
rhelmer 54fc4de
Merge pull request #166 from rhelmer/add-rally-web-platform-support
1c10038
Bump @rollup/plugin-node-resolve from 13.0.4 to 13.0.5
dependabot[bot] 22dc47b
Bump rollup from 2.56.3 to 2.57.0
dependabot[bot] 54ec924
Merge pull request #174 from mozilla-rally/dependabot/npm_and_yarn/se…
b93c577
Merge pull request #176 from mozilla-rally/dependabot/npm_and_yarn/ro…
739e370
Merge pull request #177 from mozilla-rally/dependabot/npm_and_yarn/ro…
21c02d6
Bump mocha from 9.1.1 to 9.1.2
dependabot[bot] b006ff6
Merge pull request #179 from mozilla-rally/dependabot/npm_and_yarn/mo…
5b050bc
Add a local-only "play-test" mode
rhelmer 89419f5
add very basic examples for local data collection, and provide workin…
rhelmer 8632161
ignore undefined constants that are provided by the build system
rhelmer 3d6a123
bring docs up to date
rhelmer 6955f01
remove console debug
rhelmer 6a3b082
remove unused async
rhelmer ec4cf50
test extension opens its own tab now, and disable browser console sin…
rhelmer d65a577
remove unused vars causing lint error
rhelmer 3b67641
add default tailwind css, need to add to build system
rhelmer 36d135b
check in full tailwind css until build is ready
rhelmer b0f34c1
set initial state correctly
rhelmer 470ce75
consistent formatting
rhelmer fa3cf20
remove copy of non-js files, we actually want to transform them now
rhelmer 967764d
provide a toolbar icon to get back to options page
rhelmer ff4ec40
rename index.html to options.html
rhelmer d117bf1
generate default tailwind css during build, for now
rhelmer 46e7bbd
point to in-progress rally-sdk PR, until that lands
rhelmer 534c7e5
point to open PR of rally SDK, for now
rhelmer f4df53d
refactor out redundancy
rhelmer fe20fcb
dump as CSV instead of JSON, for use in Jupyter et al
rhelmer fb9df5b
point to open PR of rally SDK, for now
rhelmer a7ab3b8
point to official rally-sdk
rhelmer ee25941
bump to 0.8.0 for rally-sdk
rhelmer e958bd6
add tailwindcss dependency
rhelmer 17c50a0
correct test target name
rhelmer 6770c84
shrink toggle button slightly
rhelmer 997b756
make download button slightly smaller
rhelmer f32c5b9
give cards more room
rhelmer ddfefa0
consistent card sizes
rhelmer 03468d0
layout suggestions from https://github.com/mozilla-rally/study-templa…
rhelmer 017a980
Merge pull request #175 from rhelmer/add-playtest-dev-mode
e10bc8f
Bump selenium-webdriver from 4.0.0-rc-1 to 4.0.0-rc-2
dependabot[bot] 2187954
Bump @rollup/plugin-commonjs from 20.0.0 to 21.0.0
dependabot[bot] c3e07c5
Bump rollup from 2.57.0 to 2.58.0
dependabot[bot] f68e9f0
Merge pull request #182 from mozilla-rally/dependabot/npm_and_yarn/ro…
35d5aa8
Merge pull request #181 from mozilla-rally/dependabot/npm_and_yarn/ro…
8aef681
Merge pull request #180 from mozilla-rally/dependabot/npm_and_yarn/se…
1a5dcb2
set up jest+typescript and integration tests for the study template UI
rhelmer 0c3d23e
use archived pageset
rhelmer 2396491
add warc of rally.m.o for testing purposes
rhelmer a3ad66a
use local warc during tests
rhelmer 1020ebf
lint should ignore webarchives
rhelmer aea719f
move ignore list to web-ext-config so it works for lint too
rhelmer e996d9d
use release Firefox, and install Chrome in CircleCI
rhelmer 5dc7a9d
do not need JRE, yet anyway
rhelmer 85146d6
run firefox in headless mode
rhelmer 721d84b
add chromedriver, and modernize circleci config
rhelmer 199877a
back out circle config changes,and add chrome deps
rhelmer a5fe69c
package developer extension for selenium tests
rhelmer cd1adf6
load browser polyfill for chrome, although web-science does not work …
rhelmer c6ef4c6
add shorter default timeout to driver.wait
rhelmer 35244c6
remote debug logging
rhelmer ddf2a3e
point to in-progress PR of rally-sdk to see if tests pass
rhelmer 132e3e9
have selenium store screenshots for debugging failures
rhelmer 1823d2b
comment out final pause, see if it passes on circle
rhelmer c94c07a
download CSV
rhelmer c4b190a
upgrade to newer node on circle docker for fs.promises.rm
rhelmer 2a92a3d
bump to 0.8.0 for rally-sdk
rhelmer 73ad25e
start adding basic tests for CSV
rhelmer 5feeb21
remove trap
rhelmer e7eec1e
Merge pull request #178 from rhelmer/update-integration-tests
68080c1
Bump chromedriver from 93.0.1 to 94.0.0
dependabot[bot] c56fd8f
Merge pull request #183 from mozilla-rally/dependabot/npm_and_yarn/ch…
a7e670d
Bump @mozilla/rally from 0.8.0 to 0.8.1
dependabot[bot] 5e47e14
Merge pull request #184 from mozilla-rally/dependabot/npm_and_yarn/mo…
ad7db25
Bump @babel/preset-env from 7.15.6 to 7.15.8
dependabot[bot] 4207897
Merge pull request #185 from mozilla-rally/dependabot/npm_and_yarn/ba…
6e7a302
Create story.md
marniepw 9ab9564
Merge remote-tracking branch 'study-template/main' into add-playtest-…
rhelmer 9f77b94
use tailwind-css and enable playtest UI
rhelmer e814a46
resolve conflict
rhelmer e55ff79
start using rally SDK
rhelmer 33e48cc
hook up control panel
rhelmer d47cf6e
remove archived test site
rhelmer e0334e5
remove example js
rhelmer ee3c271
add glean, start integrating with playtest
rhelmer 224d9ef
use searchUsagePings as namespace vs. pixel
rhelmer 5630c1f
dev-mode rally ID should be all-0
rhelmer 4e6e535
add basic glean config for testing
rhelmer 2b64339
convert glean ping to CSV, discarding types
rhelmer 5b2c948
store multiple pings in dev mode, and only store serp-visit pings
rhelmer 89ea4cd
remove debug logging
rhelmer ce60bed
only send enrollment ping once
rhelmer 9700901
more robust and simpler checks for playtest messages
rhelmer ef60ee2
set extension ID and homepage
rhelmer 924aa4c
Add study pings.
knowtheory a333c35
Finalized treatment designs
kartkand 8dacaa6
v1 functionality
kartkand dca33ca
interventionStartTime renamed to treatmentStartTime
kartkand 63e16ed
isStageOne to isPhaseOne
kartkand 6bd6d63
Tracked online services markdown file
kartkand 71e7b29
Content scripts to remove and replace Google self preferenced results…
kartkand 7f2a965
phase 2 functionality nearly complete
kartkand 3c4db05
documentation for selfPreferencing.ts and slight modifications
kartkand 71f4199
Merge branch 'main' into add-playtest-mode
ea7ce38
Merge pull request #52 from rhelmer/add-playtest-mode
cad57fd
Minor fixes
kartkand 9c17343
Never change participant's homepage if they have multiple homepages
kartkand 0b42a19
Minor fixes
kartkand 8eaec30
Online service visit collection and navigational query functionality
kartkand 53c9d74
Updated comment for alaska air metadata
kartkand 0c61eaa
navigation query match terms combined into RegEx rather than manually…
kartkand 5af748f
Instrumentation for shopping self preferencing and popular ecommerce …
kartkand b7bebac
Added Glean functionality for project
kartkand e147e6e
Updates to SERP content scripts
kartkand b110f5e
All Glean ping types are exported to CSV now instead of just serp vis…
kartkand 9486eb3
Simplifying integration test to just make sure extension installs
kartkand 2abde28
Added safety check for hardcoded 0 index in exportDataAsCsv
kartkand 75ce152
Added descriptions to data documentation pings.yaml and metrics.yaml …
kartkand 6caf591
Added popular brands associated with hotel conglomerates in navigatio…
kartkand 63d61ac
Fixed documentation for confirmationReferrerIncludesStringArray
kartkand c64a6b0
Updated Glean output data doc and small fixes to metrics.yaml
kartkand efd9699
Minor changes
kartkand 116f09e
Typesafing Glean with getPositiveInteger and ternary operators
kartkand c1d12f6
Updating choice ballot data tracking so that each ballot attempt has …
kartkand 5579abf
Notice and choice ballot send regular attention and dwell time update…
kartkand 241d7d6
Fixed ZillaSlab font location in style.css
kartkand d750001
Modify generation of replacement result
kartkand 5bc9766
Don't consider missing word links in an organic search result to be o…
kartkand 6d14f6a
Not passing Rally object to StudyModule anymore
kartkand 7b7075a
Console logging hidden behind debugging flag
kartkand 92a5f13
Updated survey config with Princeton subdomain survey completion URL
kartkand e234d2e
Created setExtendedTimeout method in Utils.ts
kartkand 61a82bd
Updated survey config object names to match their respective surveyNa…
kartkand c4eac77
Using currentTime in StudyModule.ts
kartkand e728b7c
Reorganized StudyModule for consistency and added comments
kartkand b57945e
Added comments to ContentScripts.ts
kartkand ca2d75c
Added a check to the changeSearchEngine method in api.js
kartkand 73a8b80
OnlineServiceVisitCollection only reports an event for services where…
kartkand 109d8ef
Moved search engine XML files to Princeton subdomain
kartkand 9cbc50d
Removed getCoarsenedTimestamp function, we will coarsen in backend an…
kartkand 62b1a8d
Minor changes to SERP content script getSearchAreaTopHeight and getSe…
kartkand 6e0946e
Minor changes to determining page values upon document ready state
kartkand ba77c8a
Minor fixes to selfPreferencing.ts: not getting organic results with …
kartkand d1cffd1
https://bugzilla.mozilla.org/show_bug.cgi?id=1760255 - add rally ID t…
rhelmer a3b1458
Merge pull request #77 from rhelmer/add-events-to-rally-id-metrics
rhelmer c821fae
Updated study condition weights and modified modal treatments to use …
kartkand eff93de
Merge branch 'main' of github.com:citp/search-engine-usage into main
kartkand d700046
Condition weights must all be positive so commented out conditions wi…
kartkand 1b834bd
Modified attribution tracking so that redirects are considered attrib…
kartkand aa9f1e5
Minor fixes to Google content script to fix bugs with self preference…
kartkand fd682ce
Minor fixes to Baidu script for functioanlity with async page loads
kartkand ebce8c2
Minor changes the self preferencing script functionality
kartkand 2afd0f7
Changed functionality so that self preferencing results are tracked w…
kartkand c15e949
Add links to data review
rhelmer 6eae1a7
Merge pull request #84 from mozilla-rally/add-data-review-links
rhelmer 66497a0
added links to data review doc and bugzilla ticket
jepstein 03502a1
added missing data review links
jepstein 3e09950
Merge pull request #87 from mozilla-rally/add-data-review-links-pings
jepstein 9bb727e
Updated study id in manifest.json from search-engine-usage-study@rall…
kartkand 3e41e30
add public key from bug 1762997#c3
rhelmer 20a63bc
set app id
rhelmer 26870be
add valid schemaNamespace for this study
rhelmer 5238b0c
start by default for core add-on
rhelmer f87892e
update glean docs
rhelmer aae6455
Merge pull request #96 from mozilla-rally/add-public-key
rhelmer 8177d6c
Merge pull request #97 from mozilla-rally/start-by-default
rhelmer f38f541
Modified attribution tracking to account for the possibility of trans…
kartkand 9047110
Not using remotely-hosted search engine configs as per suggestion of …
kartkand 2b757d9
Using DOMPurify to sanitize DOM manipulation as per suggestion of add…
kartkand 0f7b4d4
Change extension ID for JSObject passed for changing search engine de…
kartkand d932eff
Changing documentation for changeSearchEngine because the search engi…
kartkand 356d046
Submit commits to Glean probe-scraper
relud dc666c7
revert search engine on uninstall and fix CI failures (#109)
rhelmer 457ab15
Updating import to correctly match case of file name
kartkand c896f20
Clearing oldEngine user pref if the participant is reverting their ch…
kartkand cfe698b
Changing extensionID in experimental/api.js to actual extension ID
kartkand 5d0a5a1
Resetting default to the original in case of error in onShutdown
kartkand 8e168d4
Switched from using Yandex to Brave
kartkand 3a2fdc8
Reverting homepage upon onShutdown()
kartkand 0421622
Brave selectors fixed
kartkand f2979c3
move dependencies that get rolled up into output scripts out of devDe…
a8b19e4
sync package-lock
82e2d5f
CI runs on Linux which is case-sensitive
d65dccc
Merge pull request #112 from mozilla-rally/split-dependencies
rhelmer 3491f51
Address issue with checking of homepage if the homepage did not have …
kartkand db8fc43
Merge branch 'main' of github.com:citp/search-engine-usage into main
kartkand 57d03ac
Added functionality for reporting total number of results for a query…
kartkand 86c8b03
Bump geckodriver from 1.22.3 to 2.0.4
dependabot[bot] c5af1aa
Converting queries to compatibility decomposition form, removing all …
kartkand 897aa25
Hook up taskcluster for priv. signing, closes #37
rhelmer d43b47c
switch from -rally to -extensions org
rhelmer 8cbd06a
Use private repo for taskcluster config
rhelmer 54f32da
use main branch
rhelmer d6f1609
point to xpi-template
rhelmer 5b3b435
Update taskcluster version + python3
hneiva 30a6cb0
Update ci image version
hneiva a6346e5
Point to main branch of xpi-template
hneiva 61e49bf
Pull taskgraph from pypi
hneiva 4b45097
bump name and version number
ca31e66
rename output file to same name as declared in xpi-manifest
7275f2c
bump version to 1.1.0
f01383a
switch github repo to public
14b7a24
Merge pull request #120 from mozilla-rally/public-repo
rhelmer 4c336bc
remove rename of XPI before integration test
ee796c3
customize integration tests
ca30f2b
customize integration tests for this study
6d8db52
skip integration tests on taskcluster
bf503da
skip lint in taskcluster
20079c5
remove circular dependency, and only build tailwind in dev
972c522
break compilation into two phases to reduce memory usage
1e0d2c2
run package as part of build, for taskcluster
f613ada
Bump eslint-plugin-mocha from 8.2.0 to 10.1.0
dependabot[bot] bf674a2
Bump webextension-polyfill from 0.8.0 to 0.9.0
dependabot[bot] f73ff63
add now-required mozillaAddons perm for privileged code
36eb471
Merge pull request #119 from mozilla-rally/dependabot/npm_and_yarn/we…
rhelmer 826258c
Merge pull request #118 from mozilla-rally/dependabot/npm_and_yarn/es…
rhelmer a99443c
Bump @rollup/plugin-commonjs from 19.0.2 to 22.0.2
dependabot[bot] b859ce1
Merge pull request #25 from mozilla-rally/dependabot/npm_and_yarn/gec…
rhelmer de11fe7
Merge pull request #107 from relud/patch-1
e9cff5a
Revert "Submit commits to Glean probe-scraper"
abcab98
Merge pull request #122 from mozilla-rally/dependabot/npm_and_yarn/ro…
586a792
Implemented lottery functionality and modified long timeouts to use b…
kartkand 83b7efb
Implemented lottery functionality and modified long timeouts to use b…
kartkand fcf9621
Updated getNumResults for SERP content scripts
kartkand f38d4c7
Getting number of Google query results count for all SERPs
kartkand 5f79e72
Update to SerpVisitCollection.ts for getting number of Google query r…
kartkand 4ffa4f4
Wraaping components of SERP parsing in try/catch so one component of …
kartkand aa9edd0
Moving lottery lambda URLs to consts and documenting what they are
kartkand 848186e
Updated initial survey URL to new survey with Brave added as search e…
kartkand d0b0d19
Getting whether ad landing page is in history in InitialCollection
kartkand 9355a62
Updating SERP selectors
kartkand 81a444d
Updated SERP selectors
kartkand fb02ec6
Decommision via self-uninstall
thomik-corp 2010911
Merge pull request #154 from mozilla-rally/kill-extension
thomik-corp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 contains hidden or 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 contains hidden or 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 |
|---|---|---|
| @@ -1,80 +1,14 @@ | ||
| # Mozilla Rally study template. | ||
| The purpose of this repository is to provide a starting point to build a Rally study. It contains: | ||
| # Search Engine Usage Study | ||
| A study to assess how individuals interact with their search engines. | ||
|
|
||
| 1. an example [`manifest.json`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json) file. | ||
| 2. an example background and content script in `src/`. | ||
| 3. a rollup config file that builds the files needed for the web extension using the source files in `src/` (the background & content scripts). | ||
| 4. an example integration test that launches a browser & installs the add-on. | ||
| 5. a `web-ext-config.js` file & an eslint configuration. | ||
|
|
||
| ## Getting started | ||
|
|
||
| 1. Fork this repository. | ||
| 2. Customize the [manifest.json](./manifest.json) file: | ||
| * change the `name`, `author`, and `description` properties; | ||
| * swap the value of `application.gecko.id` (e.g. `[email protected]`) with the one provided you by the Rally team; | ||
| 3. Customize the [package.json](./package.json) file. At a bare minimum, change the `name`,`description`, `version`, `author`, `repository`, `bugs`, and `homepage` properties; | ||
| 4. Provide the encryption data to the `Rally` class constructor in the [src/background.js](./src/background.js) file: | ||
|
|
||
| ```js | ||
| rally.initialize( | ||
| // A sample key id used for encrypting data. | ||
| "sample-invalid-key-id", | ||
| // A sample *valid* JWK object for the encryption. | ||
| { | ||
| "kty":"EC", | ||
| "crv":"P-256", | ||
| "x":"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU", | ||
| "y":"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0", | ||
| "kid":"Public key used in JWS spec Appendix A.3 example" | ||
| }, | ||
| // ... other required arguments ... | ||
| ); | ||
| ``` | ||
|
|
||
| 4. From the forked repository directory, install all the NPM dependencies: | ||
|
|
||
| ```bash | ||
| fork-dir> npm install . | ||
| ``` | ||
|
|
||
| 5. Test the customized study in Firefox and commit your changes: doing this right after the initial fork provides a nice and clean cutting point with the original repository, which will simplify future updates (if needed). | ||
|
|
||
| ## Building upon this template | ||
| This template uses [rollup.js](https://rollupjs.org/) as a module bundler and NPM for dependency management. The [manifest.json](./manifest.json) file already includes a sample background scripts. | ||
|
|
||
| Dependencies can be added using the [`npm install`](https://docs.npmjs.com/cli/v6/commands/npm-install) command, using the appropriate `--save-dev` or `--save-prod` switch. This command will take care of automatically updating the [package.json](./package.json) file. | ||
|
|
||
| New modules can be added in the `src/` directory. Modules need to expose the exported functions using the `module.exports` syntax. For example, a class can be exported as follows in a `MyClass.js` file: | ||
|
|
||
| ```js | ||
| module.exports = class MyClass { | ||
| myFunc() { | ||
| console.log("Testing!"); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| And then be imported in another file with `const MyClass = require("./MyClass.js");`. | ||
|
|
||
| Plain functions can be exposed as follows in a `MyFuncs.js` file: | ||
|
|
||
| ```js | ||
| module.exports = { | ||
| myTest() { | ||
| //... something! | ||
| }, | ||
| otherFunc() { | ||
| // ... other function! | ||
| } | ||
| }; | ||
| ``` | ||
|
|
||
| And then be imported in another file with `const {myTest, otherFunc} = require("./MyFuncs.js");`. | ||
| ## Requirements | ||
| * [Node.js](https://nodejs.org/en/), available via [Homebrew](https://brew.sh/) on macOS | ||
| * [Mozilla web-ext](https://extensionworkshop.com/documentation/develop/getting-started-with-web-ext/) | ||
|
|
||
| ## Supported NPM commands | ||
| The template comes with a set of pre-defined NPM commands (to run as `npm run <command>`) to help study authors: | ||
| The repo comes with a set of pre-defined NPM commands (to run as `npm run <command>`): | ||
|
|
||
| * `compile-typescript`: Compiles the Typescript source code. The compiled code is saved in the `src/` directory. | ||
| * `build`: assembles the final addon. The bundler generated code is saved in the `dist/` directory. | ||
kartkand marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * `dev`: assembles the addon in _developer mode_. In this mode data doesn't get submitted but, instead, is dumped to the [Browser Console](https://developer.mozilla.org/en-US/docs/Tools/Browser_Console). This mode allows for a smoother development process. | ||
| * `lint`: run linting on the add-on code. | ||
|
|
@@ -85,3 +19,5 @@ The template comes with a set of pre-defined NPM commands (to run as `npm run <c | |
|
|
||
| ## Manual testing in the browser | ||
| To test, either load as a temporary add-on in Firefox (`about:debugging`) or Chrome ("developer mode" in `chrome://extensions`) or use `npm run start`. | ||
kartkand marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Debugging output is available in Tools → Web Developer → Browser Console. Make sure that the Show Content Messages option is checked. You might find it helpful to set a filter for debugging messages of interest. | ||
This file contains hidden or 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,155 @@ | ||
| /** | ||
| * @file Implementation for experimental API. | ||
kartkand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * It provides definitions for the functions and events | ||
| * defined in the schema. | ||
| * @module WebScience.Experiments.experimental | ||
kartkand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
|
|
||
| const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); | ||
|
|
||
| /** | ||
| * @description Using experiments_api feature to define new APIs linked to | ||
kartkand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * the extension. experimental is exposed under the global browser object and | ||
| * is accessible from background scripts. | ||
| */ | ||
| this.experimental = class extends ExtensionAPI { | ||
| getAPI() { | ||
| return { | ||
| experimental: { | ||
| async createPopup(searchEngineOld, searchEngineNew, modalPrimaryRevert) { | ||
kartkand marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Returns whether the search engine should be reverted. | ||
| const flags = | ||
| Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 + | ||
| Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_1; | ||
|
|
||
| if(modalPrimaryRevert) { | ||
| const x = Services.prompt.confirmEx( | ||
| null, | ||
| `Change back to ${searchEngineOld} Search?`, | ||
| `Your search engine has been changed to use ${searchEngineNew}.`, | ||
| flags, | ||
| "Change it back", | ||
| "Keep it", | ||
| null, | ||
| null, | ||
| {} | ||
| ); | ||
| return x === 0; | ||
| } else { | ||
| const x = Services.prompt.confirmEx( | ||
| null, | ||
| `Change back to ${searchEngineOld} Search?`, | ||
| `Your search engine has been changed to use ${searchEngineNew}.`, | ||
| flags, | ||
| "Keep it", | ||
| "Change it back", | ||
| null, | ||
| null, | ||
| {} | ||
| ); | ||
| return x === 1; | ||
| } | ||
| }, | ||
| /** | ||
| * Changes the user's default search engine | ||
| * | ||
| * @function | ||
kartkand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * @param {string} searchEngineName - name of search engine to make default | ||
kartkand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
| async changeSearchEngine(searchEngineNameIn) { | ||
| const searchEngineDetailsObject = { | ||
| google: { | ||
| iconURL: "https://www.google.com/favicon.ico", | ||
| alias: "@google", | ||
| }, | ||
| bing: { | ||
| iconURL: "https://www.bing.com/favicon.ico", | ||
| alias: "@bing", | ||
| }, | ||
| yahoo: { | ||
| iconURL: "https://www.yahoo.com/favicon.ico", | ||
| alias: "@yahoo", | ||
| }, | ||
| duckduckgo: { | ||
| iconURL: "https://duckduckgo.com/favicon.ico", | ||
| alias: "@duckduckgo", | ||
| }, | ||
| ecosia: { | ||
| iconURL: "https://cdn.ecosia.org/assets/images/ico/favicon.ico", | ||
| alias: "@ecosia", | ||
| }, | ||
| yandex: { | ||
| iconURL: "https://yastatic.net/iconostasis/_/KKii9ECKxo3QZnchF7ayZhbzOT8.png", | ||
| alias: "@yandex", | ||
| }, | ||
| baidu: { | ||
| iconURL: "https://www.baidu.com/favicon.ico", | ||
| alias: "@baidu", | ||
| }, | ||
| ask: { | ||
| iconURL: "https://www.ask.com/logo.png", | ||
| alias: "@ask", | ||
| }, | ||
| } | ||
kartkand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const searchEngineName = searchEngineNameIn.toLowerCase(); | ||
|
|
||
| // Wait for the search service to initialize and un-hide all the default engines | ||
| await Services.search.init() | ||
| Services.search.restoreDefaultEngines(); | ||
|
|
||
| let searchEngine = null | ||
|
|
||
| // Retrieves the engine we are attempting to make default | ||
| // from the list of installed engines | ||
| const installedSearchEngines = await Services.search.getEngines() | ||
| for(const installedSearchEngine of installedSearchEngines) { | ||
| if(installedSearchEngine.name.toLowerCase().includes(searchEngineName)) { | ||
| searchEngine = installedSearchEngine | ||
| break | ||
| } | ||
| } | ||
|
|
||
| // If the engine we are attempting to make default is not | ||
| // already installed, swe add it through an OpenSearch xml file | ||
kartkand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if(!searchEngine) { | ||
| searchEngine = await Services.search.addOpenSearchEngine(`https://citpsearch.cs.princeton.edu/searchengine/openSearch/${searchEngineName}.xml`, searchEngineDetailsObject[ searchEngineName ].iconURL) | ||
kartkand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| searchEngine.alias = searchEngineDetailsObject[ searchEngineName ].alias | ||
| } | ||
|
|
||
| // Make sure the engine is not hidden, move it to the top of the list of options, and make it the default | ||
| searchEngine.hidden = false | ||
| Services.search.moveEngine(searchEngine, 0); | ||
| Services.search.defaultEngine = searchEngine | ||
| }, | ||
| /** | ||
| * Get the user's current default search engine | ||
| * @function | ||
| */ | ||
kartkand marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async getSearchEngine() { | ||
| await Services.search.init(); | ||
| const defaultEngine = await Services.search.getDefault() | ||
| return defaultEngine ? defaultEngine.name : ""; | ||
| }, | ||
| /** | ||
| * Get the user's current default search engine | ||
kartkand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * @function | ||
| * @param {string} newHomepage - url of the new homepage | ||
| */ | ||
| changeHomepage(newHomepage) { | ||
| Services.prefs.setCharPref("browser.startup.homepage", newHomepage) | ||
| }, | ||
| /** | ||
| * Get the user's current default search engine | ||
kartkand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * @function | ||
| */ | ||
| async getHomepage() { | ||
| return Services.prefs.getCharPref("browser.startup.homepage") | ||
| }, | ||
|
|
||
|
|
||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,70 @@ | ||
| [ | ||
kartkand marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| "namespace": "experimental", | ||
| "functions": [ | ||
| { | ||
| "name": "createPopup", | ||
| "type": "function", | ||
| "description": "Create popup", | ||
| "async": true, | ||
| "parameters": [ | ||
| { | ||
| "name": "searchEngineOld", | ||
| "type": "string", | ||
| "description": "The engine that the default search was changed from." | ||
| }, | ||
| { | ||
| "name": "searchEngineNew", | ||
| "type": "string", | ||
| "description": "The engine that the default search was changed to." | ||
| }, | ||
| { | ||
| "name": "modalPrimaryRevert", | ||
| "type": "boolean", | ||
| "description": "Whether the revert button is the primary button on the modal dialog." | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "changeSearchEngine", | ||
| "type": "function", | ||
| "description": "Change the user's default search engine", | ||
| "async": true, | ||
| "parameters": [ | ||
| { | ||
| "name": "searchEngineName", | ||
| "type": "string", | ||
| "description": "name of search engine to make default" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "getSearchEngine", | ||
| "type": "function", | ||
| "description": "Get the user's current search engine", | ||
| "async": true, | ||
| "parameters": [] | ||
| }, | ||
| { | ||
| "name": "changeHomepage", | ||
| "type": "function", | ||
| "description": "Change the user's homepage", | ||
| "async": false, | ||
| "parameters": [ | ||
| { | ||
| "name": "newHomepage", | ||
| "type": "string", | ||
| "description": "url of the new homepage" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "getHomepage", | ||
| "type": "function", | ||
| "description": "Get the user's homepage", | ||
| "async": true, | ||
| "parameters": [] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.