Skip to content

Commit

Permalink
Add headers for test files and mark code to look over (issue #415)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophieeng committed Apr 21, 2023
1 parent 00ec9ca commit f268136
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/background/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { reloadDynamicRules } from "../common/editRules.js";

// TODO: Remove
import {
debug_domainlist_and_dynamicrules,
debug_domainlist_and_dynamicrules, // this isn't used
updateRemovalScript,
} from "../common/editDomainlist.js";

Expand Down Expand Up @@ -97,8 +97,8 @@ function disable() {
*/
chrome.runtime.onMessage.addListener(async function (
message,
sender,
sendResponse
sender, // not used
sendResponse // not used
) {
if (message.msg === "TURN_ON_OFF") {
let isEnabled = message.data.isEnabled; // can be undefined
Expand All @@ -113,6 +113,6 @@ chrome.runtime.onMessage.addListener(async function (
}

if (message.msg === "CHANGE_IS_DOMAINLISTED") {
let isDomainlisted = message.data.isDomainlisted; // can be undefined
let isDomainlisted = message.data.isDomainlisted; // can be undefined // not used
}
});
2 changes: 1 addition & 1 deletion src/background/cookiesIAB.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ modification process
is the boolean for checking multipel cookies correct?
----- To-Do -----
----- To-Do ----- // need to check
- Add some kind of check to stop the cookie from being updated
more than once per site refresh.
- Think about how we will disable the feature if a certain site is
Expand Down
4 changes: 2 additions & 2 deletions src/background/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const { saveAs } = pkg;
// In general, these functions should be use with async / await for
// syntactic sweetness & synchronous data handling
// i.e., await storage.set(stores.settings, extensionMode.enabled, 'MODE')
// TODO: Make this an enum
// TODO: Make this an enum // need t ocheck
const stores = Object.freeze({
settings: "SETTINGS",
domainlist: "DOMAINLIST",
Expand Down Expand Up @@ -142,7 +142,7 @@ async function handleUpload() {
alert("Error loading list");
}
}
// hardcode if it is the new version
// hardcode if it is the new version // check
if (Number(version[0]) >= 3) {
reloadDynamicRules();
updateRemovalScript();
Expand Down
4 changes: 2 additions & 2 deletions src/common/editDomainlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
// TODO: Migrate editRules & editDomainlist to one file

/*************************** FILE ROADMAP ******************************/

// check
/*
Here are a few functions that are either implemented already or might be
worthwhile to implement down the road (for adding things to the lists
Expand Down Expand Up @@ -178,7 +178,7 @@ async function removeDomainFromDomainlistAndRules(domain) {
/******************************************************************************/

async function debug_domainlist_and_dynamicrules() {
let sampleSites = [
let sampleSites = [ // not called
"a.com",
"b.com",
"c.com",
Expand Down
6 changes: 3 additions & 3 deletions src/content-scripts/contentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async function getWellknown(url) {
/* MAIN CONTENT SCRIPT PROCESSES GO HERE */

let url = new URL(location); // location object
////not sure if this stuff needs to stay or go
////not sure if this stuff needs to stay or go // check
/* (1) Gets Frame:0 Tab content */
// leave this commented out while debugging ANALYSIS MODE
// chrome.runtime.sendMessage({
Expand Down Expand Up @@ -107,7 +107,7 @@ async function getWellknown(url) {
/******************************************************************************/
/******************************************************************************/

chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { // check unused arguments
if (message.msg === "USPAPI_FETCH_REQUEST") {
injectScript(uspapiRequest);
}
Expand All @@ -118,7 +118,7 @@ window.addEventListener(
function (event) {
if (
event.data.type == "USPAPI_TO_CONTENT_SCRIPT"
// && typeof chrome.app.isInstalled !== 'undefined'
// && typeof chrome.app.isInstalled !== 'undefined' // delete
) {
chrome.runtime.sendMessage({
msg: "USPAPI_TO_BACKGROUND",
Expand Down
2 changes: 1 addition & 1 deletion src/options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ import "../../node_modules/tippy.js/dist/tippy-bundle.umd.js";
* Intializes scripts that build the options page
*/
document.addEventListener("DOMContentLoaded", (event) => {
mainView();
mainView(); // check event
});
4 changes: 2 additions & 2 deletions src/options/views/main-view/main-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export async function mainView() {
//Listener: Listens for a message sent by popup.js
chrome.runtime.onMessage.addListener(function (
message,
sender,
sendResponse
sender, // seem to not be used
sendResponse // seem to not be used
) {
if (message.msg === "DARKSWITCH_PRESSED") {
darkmode.toggle();
Expand Down
2 changes: 1 addition & 1 deletion src/options/views/settings-view/settings-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import UIkit from "../../../../node_modules/uikit/dist/js/uikit.js";
import tippy from "../../../../node_modules/tippy.js/dist/tippy-bundle.umd.js";

import "../../../../node_modules/file-saver/src/FileSaver.js";
import Darkmode from "darkmode-js";
import Darkmode from "darkmode-js"; // check darkmode
import {
addDynamicRule,
deleteAllDynamicRules,
Expand Down
11 changes: 11 additions & 0 deletions test/background/gpc.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
gpc.test.js
================================================================================
gpc.test.js tests the GPC signal head-fully using Puppeteer and Chromium
*/

/**
* Tests for testing GPC signals
*/
Expand Down
11 changes: 11 additions & 0 deletions test/background/isValidSignalIAB.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
isValidSignalIAB.test.js
================================================================================
isValidSignalIAB.test.js tests the IAB signals by checking valid inputs for the isValidSignalIAB function
*/

import assert from 'assert';
import {isValidSignalIAB} from '../../src/background/cookiesIAB.js';

Expand Down
23 changes: 11 additions & 12 deletions test/background/makeCookieIAB.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import assert from "assert";
import { makeCookieIAB } from "../../src/background/cookiesIAB.js";
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

// function makeCookieIAB(name, value, url) {
// var time = new Date();
// var now = time.getTime();
/*
makeCookieIAB.test.js
================================================================================
makeCookieIAB.test.js makes a new cookie and checks against expected cookie values
*/

// let cookie = {};
// cookie.expirationDate = now / 1000 + 31557600;
// cookie.url = url;
// cookie.name = name;
// cookie.value = value;
// return cookie;
// }
import assert from "assert";
import { makeCookieIAB } from "../../src/background/cookiesIAB.js";

it("checks whether a new cookie is constructed per the IAB spec", () => {
var name = "test_cookie";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
parseIAB.test.js
================================================================================
parseIAB.test.js checks to make sure IAB signal is parsed correctly with Y as the third character
*/

import assert from "assert";
import { parseIAB } from "../../src/background/cookiesIAB.js";

Expand Down
12 changes: 12 additions & 0 deletions test/background/pruneCookieIAB.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
pruneCookieIAB.test.js
================================================================================
pruneCookieIAB.test.js makes a cookie and checks various properties of the new cookie
*/


import assert from "assert";
import { pruneCookieIAB } from "../../src/background/cookiesIAB.js";
import { makeCookieIAB } from "../../src/background/cookiesIAB.js";
Expand Down

0 comments on commit f268136

Please sign in to comment.