Skip to content

Commit 800a240

Browse files
authored
ntp: support empty strings in persistent storage (#1932)
* ntp: support empty strings in persistent storage * return values as stored
1 parent 6637e02 commit 800a240

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

special-pages/pages/new-tab/app/omnibar/integration-tests/omnibar.page.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ export class OmnibarPage {
252252
}
253253
}
254254
}
255+
256+
async clearsInput() {
257+
await this.searchInput().hover();
258+
await this.closeButton().click();
259+
}
255260
}
256261

257262
/**

special-pages/pages/new-tab/app/omnibar/integration-tests/omnibar.persistence.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ test.describe('omnibar widget persistence', () => {
2828
// back to second again
2929
await omnibar.didSwitchToTab('02', ['01', '02']);
3030
await omnibar.expectInputValue('dresses');
31+
32+
// now clear the input
33+
await omnibar.clearsInput();
34+
35+
// first tab is all good...
36+
await omnibar.didSwitchToTab('01', ['01', '02']);
37+
await omnibar.expectInputValue('shoes');
38+
39+
/// ...but the tab where we cleared is still empty
40+
await omnibar.didSwitchToTab('02', ['01', '02']);
41+
await omnibar.expectInputValue('');
3142
});
3243
test('remembers `mode` across tabs', async ({ page }, workerInfo) => {
3344
const ntp = NewtabPage.create(page, workerInfo);

special-pages/pages/new-tab/app/tabs/PersistentValue.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class PersistentValue {
1717
* @param {T} args.value
1818
*/
1919
update({ id, value }) {
20-
if (string(id) && string(value)) {
20+
if (string(id)) {
2121
this.#values.set(id, value);
2222
}
2323
}
@@ -63,7 +63,7 @@ export class PersistentValue {
6363
byId(id) {
6464
if (typeof id !== 'string') return null;
6565
const value = this.#values.get(id);
66-
if (!value || !string(value)) return null;
66+
if (value === undefined) return null;
6767
return value;
6868
}
6969

0 commit comments

Comments
 (0)