refactor: 리펙토링
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
} from "../../src/contracts/cache-invalidation.ts";
|
||||
import {
|
||||
createBrowserCrossContextInvalidation,
|
||||
createBrowserCrossContextInvalidationFromHost,
|
||||
type BroadcastChannelFacade,
|
||||
type BroadcastMessageListener,
|
||||
type BrowserCrossContextInvalidationDependencies,
|
||||
@@ -21,7 +22,7 @@ import {
|
||||
|
||||
const NOW = 1_000_000;
|
||||
const CACHE_EPOCH = "cache-epoch-0001";
|
||||
const TOPIC = "reference-resources";
|
||||
const TOPIC = "sample-topic-alpha";
|
||||
const CHANNEL_NAME = "cache-invalidation-v1";
|
||||
const STORAGE_PULSE_KEY = "ca-frontend:cache-invalidation:v1:pulse";
|
||||
|
||||
@@ -307,6 +308,30 @@ describe("cache invalidation wire contract", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("browser cross-context host", () => {
|
||||
it("does not inspect browser capabilities when no topic is installed", () => {
|
||||
const reads: string[] = [];
|
||||
const host = new Proxy<Record<string, unknown>>(
|
||||
{},
|
||||
{
|
||||
get(_target, property) {
|
||||
reads.push(String(property));
|
||||
throw new DOMException("Capability access denied", "SecurityError");
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(
|
||||
createBrowserCrossContextInvalidationFromHost({
|
||||
host,
|
||||
cacheEpoch: CACHE_EPOCH,
|
||||
topics: [],
|
||||
}),
|
||||
).toBeUndefined();
|
||||
expect(reads).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("browser cross-context invalidation transport", () => {
|
||||
it("publishes one exact BroadcastChannel event and filters self echo", () => {
|
||||
const network = new FakeBroadcastNetwork();
|
||||
@@ -525,7 +550,7 @@ describe("browser cross-context invalidation transport", () => {
|
||||
true,
|
||||
);
|
||||
expect(JSON.stringify(observations)).not.toMatch(
|
||||
/sensitive-event-identifier|reference-resources|cache-epoch-0001/,
|
||||
/sensitive-event-identifier|sample-topic-alpha|cache-epoch-0001/,
|
||||
);
|
||||
runtime.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user