Skip to content

Commit

Permalink
Merge branch 'main' into jkt/seenBeforeDay
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanKingston authored Nov 2, 2023
2 parents d4d6201 + 8e765d9 commit 5090f57
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
Expand All @@ -26,7 +26,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.version }}
cache: 'npm'
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
Expand All @@ -53,7 +53,7 @@ jobs:
shard: [1/4, 2/4, 3/4, 4/4]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ddg2dnr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'
Expand All @@ -27,7 +27,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/privacy-grade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
Expand All @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
if: "contains(github.event.head_commit.message, 'ci release')"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ BUILD_TARGETS += $(BUILD_DIR)/public/js/inject.js
## SASS
SASS = node_modules/.bin/sass
SCSS_SOURCE = $(shell find shared/scss/ -type f)
OUTPUT_CSS_FILES = $(BUILD_DIR)/public/css/noatb.css $(BUILD_DIR)/public/css/options.css $(BUILD_DIR)/public/css/feedback.css
OUTPUT_CSS_FILES = $(BUILD_DIR)/public/css/options.css $(BUILD_DIR)/public/css/feedback.css
$(BUILD_DIR)/public/css/base.css: shared/scss/base/base.scss $(SCSS_SOURCE)
$(SASS) $< $@
$(BUILD_DIR)/public/css/%.css: shared/scss/%.scss $(SCSS_SOURCE)
Expand Down
15 changes: 0 additions & 15 deletions browsers/chrome-mv3/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@
"extension_pages": "script-src 'self'; object-src 'self'; frame-ancestors https://duckduckgo.com https://*.duckduckgo.com"
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"exclude_matches": [
"*://localhost/*",
"*://*.localhost/*"
],
"match_about_blank": true,
"all_frames": true,
"css": [
"public/css/noatb.css"
],
"run_at": "document_start"
},
{
"js": [
"public/js/content-scripts/autofill.js"
Expand Down
3 changes: 0 additions & 3 deletions browsers/chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
],
"match_about_blank": true,
"all_frames": true,
"css": [
"public/css/noatb.css"
],
"js": [
"public/js/inject.js"
],
Expand Down
3 changes: 0 additions & 3 deletions browsers/firefox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
],
"match_about_blank": true,
"all_frames": true,
"css": [
"public/css/noatb.css"
],
"js": [
"public/js/inject.js"
],
Expand Down
4 changes: 2 additions & 2 deletions integration-test/atb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test.describe('install workflow', () => {
})

// try get ATB params
await backgroundPage.evaluate(() => globalThis.dbg.atb.updateATBValues())
await backgroundPage.evaluate(async () => globalThis.dbg.atb.updateATBValues(await globalThis.dbg.Wrapper.getDDGTabUrls()))

// wait for an exti call
// eslint-disable-next-line no-unmodified-loop-condition
Expand Down Expand Up @@ -87,7 +87,7 @@ test.describe('install workflow', () => {
await page.goto('https://duckduckgo.com/?natb=v123-4ab&cp=atbhc', { waitUntil: 'networkidle' })

// try get ATB params again
await backgroundPage.evaluate(() => globalThis.dbg.atb.updateATBValues())
await backgroundPage.evaluate(async () => globalThis.dbg.atb.updateATBValues(await globalThis.dbg.Wrapper.getDDGTabUrls()))
// eslint-disable-next-line no-unmodified-loop-condition
while (numExtiCalled < 0) {
page.waitForTimeout(100)
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-node": "^11.1.0",
"fake-indexeddb": "^5.0.0",
"fake-indexeddb": "^5.0.1",
"glob": "^10.3.10",
"jasmine": "5.0.2",
"jsdom": "^22.0.0",
Expand All @@ -55,7 +55,7 @@
"karma-source-map-support": "1.4.0",
"node-fetch": "^3.3.2",
"puppeteer": "^19.3.0",
"sass": "^1.69.4",
"sass": "^1.69.5",
"standard": "17.1.0",
"timekeeper": "^2.3.1",
"typescript": "^5.2.2",
Expand Down
7 changes: 3 additions & 4 deletions shared/js/background/atb.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,14 @@ const ATB = (() => {
return new URLSearchParams()
},

updateATBValues: () => {
updateATBValues: (ddgTabUrls) => {
// wait until settings is ready to try and get atb from the page
return settings.ready()
.then(ATB.setInitialVersions)
.then(browserWrapper.getDDGTabUrls)
.then((urls) => {
.then(() => {
let atb
let params
urls.some(url => {
ddgTabUrls.some(url => {
params = ATB.getAcceptedParamsFromURL(url)
atb = params.has('atb') && params.get('atb')
return !!atb
Expand Down
3 changes: 2 additions & 1 deletion shared/js/background/broken-site-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ export async function breakageReportForTab ({
urlParametersRemoved,
ctlYouTube,
ctlFacebookPlaceholderShown,
ctlFacebookLogin
ctlFacebookLogin,
protectionsState: tab.site.isFeatureEnabled('contentBlocking') ? '1' : '0'
})

for (const [key, value] of Object.entries(requestCategories)) {
Expand Down
4 changes: 3 additions & 1 deletion shared/js/background/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ async function onInstalled (details) {
tdsStorage.initOnInstall()

if (details.reason.match(/install/)) {
// get tab URLs immediately to prevent race with install page
const ddgTabUrls = await browserWrapper.getDDGTabUrls()
await settings.ready()
settings.updateSetting('showWelcomeBanner', true)
if (browserName === 'chrome') {
settings.updateSetting('showCounterMessaging', true)
settings.updateSetting('shouldFireIncontextEligibilityPixel', true)
}
await ATB.updateATBValues()
await ATB.updateATBValues(ddgTabUrls)
await ATB.openPostInstallPage()

if (browserName === 'chrome') {
Expand Down
8 changes: 0 additions & 8 deletions shared/js/background/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@ export function mergeSavedSettings (settings, results) {

export async function getDDGTabUrls () {
const tabs = await browser.tabs.query({ url: 'https://*.duckduckgo.com/*' }) || []

tabs.forEach(tab => {
insertCSS({
target: { tabId: tab.id },
files: ['/public/css/noatb.css']
})
})

return tabs.map(tab => tab.url)
}

Expand Down
3 changes: 0 additions & 3 deletions shared/scss/noatb.scss

This file was deleted.

20 changes: 3 additions & 17 deletions unit-test/background/atb.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,37 +249,23 @@ describe('complex install workflow cases', () => {
})

it('should handle the install process correctly if there\'s no DDG pages open', () => {
spyOn(browser.tabs, 'query').and.returnValue(Promise.resolve([]))

return atb.updateATBValues()
return atb.updateATBValues([])
.then(() => {
validateExtiWasHit('v112-2')
expect(settings.getSetting('atb')).toEqual('v112-2')
expect(settings.getSetting('set_atb')).toEqual('v112-2')
})
})
it('should handle the install process correctly if there\'s DDG pages open that pass an ATB param', () => {
// pretend one of the pages has an ATB to pass
spyOn(browser.tabs, 'query').and.returnValue([
{ url: 'https://duckduckgo.com/about' },
{ url: 'https://duckduckgo.com/?natb=v112-2ab' }
])

return atb.updateATBValues()
return atb.updateATBValues(['https://duckduckgo.com/about', 'https://duckduckgo.com/?natb=v112-2ab'])
.then(() => {
validateExtiWasHit('v112-2ab')
expect(settings.getSetting('atb')).toEqual('v112-2ab')
expect(settings.getSetting('set_atb')).toEqual('v112-2ab')
})
})
it('should handle the install process correctly if there\'s DDG pages open that do not pass an ATB param', () => {
// pretend no pages have ATB to pass
spyOn(browser.tabs, 'query').and.returnValue([
{ url: 'https://duckduckgo.com/about' },
{ url: 'https://duckduckgo.com/?q=test' }
])

return atb.updateATBValues()
return atb.updateATBValues(['https://duckduckgo.com/about', 'https://duckduckgo.com/?q=test'])
.then(() => {
validateExtiWasHit('v112-2')
expect(settings.getSetting('atb')).toEqual('v112-2')
Expand Down
Loading

0 comments on commit 5090f57

Please sign in to comment.