Skip to content

Commit

Permalink
Release build 6.19.0 [ci release]
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanKingston authored and github-actions[bot] committed Sep 25, 2024
1 parent 381f152 commit 1ed5696
Show file tree
Hide file tree
Showing 13 changed files with 280 additions and 58 deletions.
16 changes: 16 additions & 0 deletions Sources/ContentScopeScripts/dist/contentScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -2583,6 +2583,9 @@
if (this.getFeatureSettingEnabled("screenLock")) {
this.screenLockFix();
}
if (this.getFeatureSettingEnabled("modifyLocalStorage")) {
this.modifyLocalStorage();
}
}
/** Shim Web Share API in Android WebView */
shimWebShare() {
Expand Down Expand Up @@ -2948,6 +2951,19 @@
} catch {
}
}
/**
* Support for modifying localStorage entries
*/
modifyLocalStorage() {
const settings = this.getFeatureSetting("modifyLocalStorage");
if (!settings || !settings.changes)
return;
settings.changes.forEach((change) => {
if (change.action === "delete") {
localStorage.removeItem(change.key);
}
});
}
/**
* Support for proxying `window.webkit.messageHandlers`
*/
Expand Down
20 changes: 20 additions & 0 deletions build/android/contentScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -7899,6 +7899,10 @@
if (this.getFeatureSettingEnabled('screenLock')) {
this.screenLockFix();
}

if (this.getFeatureSettingEnabled('modifyLocalStorage')) {
this.modifyLocalStorage();
}
}

/** Shim Web Share API in Android WebView */
Expand Down Expand Up @@ -8313,6 +8317,22 @@
}
}

/**
* Support for modifying localStorage entries
*/
modifyLocalStorage () {
/** @type {import('../types//webcompat-settings').WebCompatSettings['modifyLocalStorage']} */
const settings = this.getFeatureSetting('modifyLocalStorage');

if (!settings || !settings.changes) return

settings.changes.forEach((change) => {
if (change.action === 'delete') {
localStorage.removeItem(change.key);
}
});
}

/**
* Support for proxying `window.webkit.messageHandlers`
*/
Expand Down
20 changes: 20 additions & 0 deletions build/contentScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -14606,6 +14606,10 @@
if (this.getFeatureSettingEnabled('screenLock')) {
this.screenLockFix();
}

if (this.getFeatureSettingEnabled('modifyLocalStorage')) {
this.modifyLocalStorage();
}
}

/** Shim Web Share API in Android WebView */
Expand Down Expand Up @@ -15020,6 +15024,22 @@
}
}

/**
* Support for modifying localStorage entries
*/
modifyLocalStorage () {
/** @type {import('../types//webcompat-settings').WebCompatSettings['modifyLocalStorage']} */
const settings = this.getFeatureSetting('modifyLocalStorage');

if (!settings || !settings.changes) return

settings.changes.forEach((change) => {
if (change.action === 'delete') {
localStorage.removeItem(change.key);
}
});
}

/**
* Support for proxying `window.webkit.messageHandlers`
*/
Expand Down
20 changes: 20 additions & 0 deletions build/integration/contentScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -14606,6 +14606,10 @@
if (this.getFeatureSettingEnabled('screenLock')) {
this.screenLockFix();
}

if (this.getFeatureSettingEnabled('modifyLocalStorage')) {
this.modifyLocalStorage();
}
}

/** Shim Web Share API in Android WebView */
Expand Down Expand Up @@ -15020,6 +15024,22 @@
}
}

/**
* Support for modifying localStorage entries
*/
modifyLocalStorage () {
/** @type {import('../types//webcompat-settings').WebCompatSettings['modifyLocalStorage']} */
const settings = this.getFeatureSetting('modifyLocalStorage');

if (!settings || !settings.changes) return

settings.changes.forEach((change) => {
if (change.action === 'delete') {
localStorage.removeItem(change.key);
}
});
}

/**
* Support for proxying `window.webkit.messageHandlers`
*/
Expand Down
2 changes: 1 addition & 1 deletion integration-test/playwright/webcompat.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('web compat', async ({ page }, testInfo) => {
})

export class WebcompatSpec {
htmlPage = '/webcompat/index.html'
htmlPage = '/webcompat/pages/message-handlers.html'
config = './integration-test/test-pages/webcompat/config/message-handlers.json'

/**
Expand Down
7 changes: 7 additions & 0 deletions integration-test/test-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,11 @@ describe('Test integration pages', () => {
`${process.cwd()}/integration-test/test-pages/webcompat/config/shims.json`
)
})

it('Properly modifies localStorage entries', async () => {
await testPage(
'webcompat/pages/modify-localstorage.html',
`${process.cwd()}/integration-test/test-pages/webcompat/config/modify-localstorage.json`
)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"unprotectedTemporary": [],
"features": {
"webCompat": {
"exceptions": [],
"state": "enabled",
"settings": {
"windowSizing": "enabled",
"navigatorCredentials": "enabled",
"safariObject": "enabled",
"modifyLocalStorage": {
"state": "enabled",
"changes": []
},
"domains": [
{
"domain": ["localhost", "privacy-test-pages.site"],
"patchSettings": [
{
"op": "add",
"path": "/modifyLocalStorage/changes/-",
"value": {
"key": "keyToBeDeleted",
"action": "delete"
}
},
{
"op": "add",
"path": "/modifyLocalStorage/changes/-",
"value": {
"key": "nonexistentKey",
"action": "delete"
}
}
]
}
]
}
}
}
}
59 changes: 7 additions & 52 deletions integration-test/test-pages/webcompat/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,15 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Webcompat</title>
<title>Webcompat Interventions</title>
<link rel="stylesheet" href="../shared/style.css">
</head>
<body>
<script src="../shared/utils.js"></script>

<p>Webcompat, Message Handlers</p>
<script>
test('webkit.messageHandlers - polyfill prevents throw', async () => {
let notThrown = true;
try {
window.webkit.messageHandlers.anythingatall.postMessage({})
} catch (e) {
notThrown = false
}
return [
{ name: 'Error not thrown polyfil', result: notThrown, expected: true },
]
})
test('webkit.messageHandlers - undefined should throw', async () => {
let thrown = false;
try {
window.webkit.messageHandlers.jsHandler.postMessage({})
} catch (e) {
thrown = true
}
return [
{ name: 'undefined handler should throw', result: thrown, expected: true },
]
})
test('webkit.messageHandlers - reflected message', async () => {
window.webkit.messageHandlers.printHandler = {
postMessage() {
return { test: "test" }
}
}

const value = window.webkit.messageHandlers.printHandler.postMessage({});

return [
{ name: 'reflected message should pass through', result: value.test, expected: 'test' },
]
})
renderResults();

async function captureError(fn) {
try {
// ensure Promise.reject is captured
return fn().catch(e => e)
} catch (e) {
return e
}
}

</script>
<p><a href="../../index.html">[Home]</a></p>
<ul>
<li><a href="./pages/message-handlers.html">Message Handlers</a> - <a href="./config/message-handlers.json">Config</a></li>
<li><a href="./pages/shims.html">Shims</a> - <a href="./config/shims.json">Config</a></li>
<li><a href="./pages/modify-localstorage.html">Modify localStorage</a> - <a href="./config/modify-localstorage.json">Config</a></li>
</ul>
</body>
</html>
62 changes: 62 additions & 0 deletions integration-test/test-pages/webcompat/pages/message-handlers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Webcompat</title>
<link rel="stylesheet" href="../../shared/style.css">
</head>
<body>
<script src="../../shared/utils.js"></script>

<p>Webcompat, Message Handlers</p>
<script>
test('webkit.messageHandlers - polyfill prevents throw', async () => {
let notThrown = true;
try {
window.webkit.messageHandlers.anythingatall.postMessage({})
} catch (e) {
notThrown = false
}
return [
{ name: 'Error not thrown polyfil', result: notThrown, expected: true },
]
})
test('webkit.messageHandlers - undefined should throw', async () => {
let thrown = false;
try {
window.webkit.messageHandlers.jsHandler.postMessage({})
} catch (e) {
thrown = true
}
return [
{ name: 'undefined handler should throw', result: thrown, expected: true },
]
})
test('webkit.messageHandlers - reflected message', async () => {
window.webkit.messageHandlers.printHandler = {
postMessage() {
return { test: "test" }
}
}

const value = window.webkit.messageHandlers.printHandler.postMessage({});

return [
{ name: 'reflected message should pass through', result: value.test, expected: 'test' },
]
})
renderResults();

async function captureError(fn) {
try {
// ensure Promise.reject is captured
return fn().catch(e => e)
} catch (e) {
return e
}
}

</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Modify localStorage</title>
<link rel="stylesheet" href="../../shared/style.css">
<script>
window.localStorage.setItem('keyToBeDeleted', 'valueToBeDeleted')
window.localStorage.setItem('otherKey', 'valueToRemain')
</script>
</head>
<body>
<script src="../../shared/utils.js"></script>
<p><a href="../index.html">[WebCompat]</a></p>

<p>This page verifies that localStorage modifications work properly given the <a href="../config/modify-localstorage.json">config</a>. At this time, only deletion is supported.</p>

<script>
// eslint-disable-next-line no-undef
test('Only specified localStorage entry should be removed', async () => {
const specifiedKey = window.localStorage.getItem('keyToBeDeleted')
const nonexistentKey = window.localStorage.getItem('nonexistentKey')
const otherKey = window.localStorage.getItem('otherKey')

return [
{ name: 'specified localStorage entry deleted', result: specifiedKey, expected: null },
{ name: 'specified localStorage entry that is not present on page load', result: nonexistentKey, expected: null },
{ name: 'other localStorage entry untouched', result: otherKey, expected: 'valueToRemain' }
];
});

// eslint-disable-next-line no-undef
renderResults();
</script>
</body>
</html>
6 changes: 2 additions & 4 deletions package-lock.json

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

Loading

0 comments on commit 1ed5696

Please sign in to comment.