@next/playwright 16.3.0-canary.62 → 16.3.0-canary.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -5
- package/dist/index.js +28 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,16 +11,14 @@ interface PlaywrightBrowserContext {
|
|
|
11
11
|
url?: string;
|
|
12
12
|
domain?: string;
|
|
13
13
|
path?: string;
|
|
14
|
+
expires?: number;
|
|
14
15
|
}>): Promise<void>;
|
|
15
16
|
cookies(): Promise<Array<{
|
|
16
17
|
name: string;
|
|
17
18
|
value: string;
|
|
19
|
+
domain: string;
|
|
20
|
+
path: string;
|
|
18
21
|
}>>;
|
|
19
|
-
clearCookies(options?: {
|
|
20
|
-
name?: string;
|
|
21
|
-
domain?: string;
|
|
22
|
-
path?: string;
|
|
23
|
-
}): Promise<void>;
|
|
24
22
|
}
|
|
25
23
|
interface PlaywrightPage {
|
|
26
24
|
url(): string;
|
package/dist/index.js
CHANGED
|
@@ -50,11 +50,34 @@ async function instant(page, fn, options) {
|
|
|
50
50
|
return await fn();
|
|
51
51
|
}
|
|
52
52
|
finally {
|
|
53
|
-
// Release the lock by
|
|
54
|
-
// cookie
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
53
|
+
// Release the lock by expiring the instant cookie, leaving every other
|
|
54
|
+
// cookie untouched.
|
|
55
|
+
//
|
|
56
|
+
// We must NOT use `context.clearCookies({ name: INSTANT_COOKIE })` here.
|
|
57
|
+
// Playwright implements a filtered `clearCookies` by clearing the ENTIRE
|
|
58
|
+
// cookie jar and then re-adding the cookies that don't match the filter.
|
|
59
|
+
// That briefly removes the application's own cookies too. Next.js reacts
|
|
60
|
+
// to the instant cookie's deletion by immediately re-rendering, and if
|
|
61
|
+
// that render's request races the empty window it observes none of the
|
|
62
|
+
// app's cookies (e.g. a navigated page renders as if no cookies were set).
|
|
63
|
+
//
|
|
64
|
+
// Instead we read the instant cookie's stored entries (Next.js may have
|
|
65
|
+
// updated the value, e.g. from [0] to [1,null], but preserves the domain
|
|
66
|
+
// and path) and re-add each with a past expiry, which deletes only those
|
|
67
|
+
// entries without disturbing the rest of the jar.
|
|
68
|
+
await (0, step_1.step)('Release Instant Lock', async () => {
|
|
69
|
+
const instantCookies = (await page.context().cookies()).filter((cookie) => cookie.name === INSTANT_COOKIE);
|
|
70
|
+
if (instantCookies.length > 0) {
|
|
71
|
+
await page.context().addCookies(instantCookies.map((cookie) => ({
|
|
72
|
+
name: cookie.name,
|
|
73
|
+
value: cookie.value,
|
|
74
|
+
domain: cookie.domain,
|
|
75
|
+
path: cookie.path,
|
|
76
|
+
// A past expiry (Unix epoch seconds) deletes the cookie.
|
|
77
|
+
expires: 1,
|
|
78
|
+
})));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
58
81
|
}
|
|
59
82
|
}
|
|
60
83
|
/**
|