@voila.dev/replay 0.1.0 → 0.1.1
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/README.md +4 -1
- package/dist/send.js +2 -4
- package/dist/testing/cases.d.ts +5 -0
- package/dist/testing.js +10 -0
- package/package.json +1 -1
- package/src/send/index.ts +4 -3
- package/src/testing/cases.ts +3 -0
- package/src/testing/oracle.ts +11 -0
package/README.md
CHANGED
|
@@ -41,11 +41,14 @@ Recorder: Safari 15.4, Chrome and Edge 92, Firefox 90 and later. Below, `record`
|
|
|
41
41
|
|
|
42
42
|
```
|
|
43
43
|
bun test test/unit # format, sending, joining chunks
|
|
44
|
-
npm run test:browser #
|
|
44
|
+
npm run test:browser # 48 cases, each also played back through a checkpoint, then the budget, a module that throws and the cache return; Chromium, WebKit and Firefox
|
|
45
|
+
node test/browser/visit.mjs # a visit end to end: sending, beacon on the way out, back from the cache, the copy played
|
|
45
46
|
node test/browser/fuzz.mjs # random mutations, the copy judged after each round
|
|
46
47
|
npm run size
|
|
47
48
|
```
|
|
48
49
|
|
|
50
|
+
The browser suites take `--target`, one or several of `chromium`, `webkit`, `firefox` (Playwright), `android` (Chrome on a running emulator, through adb), `ios` (Safari in a booted iOS Simulator), `firefox-esr` (a stock Firefox, `REPLAY_FIREFOX=/path/to/firefox`) and `device` (any browser that opens the URL printed). Where nothing drives the browser, the page runs the suite itself and posts what it finds back to the lab's server.
|
|
51
|
+
|
|
49
52
|
## License
|
|
50
53
|
|
|
51
54
|
MIT
|
package/dist/send.js
CHANGED
|
@@ -130,10 +130,7 @@ function connect(o) {
|
|
|
130
130
|
for (let round = 0; round < 3; round++) {
|
|
131
131
|
if (answer?.snap) o.onSnap?.();
|
|
132
132
|
const need = (answer?.need || []).filter((h) => kept.has(h));
|
|
133
|
-
if (
|
|
134
|
-
for (const h of local.keys()) if (!need.includes(h)) kept.delete(h);
|
|
135
|
-
}
|
|
136
|
-
if (!need.length) return;
|
|
133
|
+
if (!need.length) break;
|
|
137
134
|
for (const h of need) wanted.add(h);
|
|
138
135
|
const blobs = {};
|
|
139
136
|
for (const h of need) blobs[h] = kept.get(h);
|
|
@@ -143,6 +140,7 @@ function connect(o) {
|
|
|
143
140
|
kept.delete(h);
|
|
144
141
|
}
|
|
145
142
|
}
|
|
143
|
+
for (const h of local.keys()) kept.delete(h);
|
|
146
144
|
}
|
|
147
145
|
function current() {
|
|
148
146
|
const head = o.head();
|
package/dist/testing/cases.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export interface Case {
|
|
|
13
13
|
readonly select?: ReadonlyArray<readonly [string, string]>;
|
|
14
14
|
/** Strings that must never leave the page, in clear. */
|
|
15
15
|
readonly secrets?: ReadonlyArray<string>;
|
|
16
|
+
/** What the browser must offer for the case to mean anything; skipped otherwise. */
|
|
17
|
+
readonly needs?: {
|
|
18
|
+
readonly what: string;
|
|
19
|
+
readonly test: (w: Window & typeof globalThis) => boolean;
|
|
20
|
+
};
|
|
16
21
|
}
|
|
17
22
|
export declare const CASES: ReadonlyArray<Case>;
|
|
18
23
|
export {};
|
package/dist/testing.js
CHANGED
|
@@ -615,6 +615,7 @@ var CASES = [
|
|
|
615
615
|
{
|
|
616
616
|
name: "adoptedStyleSheets",
|
|
617
617
|
group: "styles",
|
|
618
|
+
needs: { what: "feuilles constructibles (Safari 16.4)", test: (w) => "adoptedStyleSheets" in w.Document.prototype },
|
|
618
619
|
html: D('<p class="a">a</p><div id="h"></div>'),
|
|
619
620
|
run: async (d, w, wait) => {
|
|
620
621
|
const s1 = new w.CSSStyleSheet();
|
|
@@ -688,6 +689,14 @@ function compare(live, copy, o = {}) {
|
|
|
688
689
|
}
|
|
689
690
|
};
|
|
690
691
|
const cssAbs = (t) => t.replace(CSS_URL, (_m, _q, u) => `url("${abs(u)}")`);
|
|
692
|
+
const refused = (name) => {
|
|
693
|
+
try {
|
|
694
|
+
copy.createAttribute(name);
|
|
695
|
+
return false;
|
|
696
|
+
} catch {
|
|
697
|
+
return true;
|
|
698
|
+
}
|
|
699
|
+
};
|
|
691
700
|
const rules = (sheet) => {
|
|
692
701
|
try {
|
|
693
702
|
return Array.from(sheet.cssRules, (r) => r.cssText).join("\n");
|
|
@@ -764,6 +773,7 @@ function compare(live, copy, o = {}) {
|
|
|
764
773
|
return [abs(u || ""), ...s].join(" ");
|
|
765
774
|
}).join(", ");
|
|
766
775
|
else if (name === "style" && side === "live") v = cssAbs(v);
|
|
776
|
+
if (side === "live" && refused(name)) continue;
|
|
767
777
|
m.set(name, v);
|
|
768
778
|
}
|
|
769
779
|
return m;
|
package/package.json
CHANGED
package/src/send/index.ts
CHANGED
|
@@ -219,12 +219,12 @@ export function connect(o: ConnectOptions): Link {
|
|
|
219
219
|
}),
|
|
220
220
|
);
|
|
221
221
|
let answer = await attempt(body);
|
|
222
|
-
// A piece may itself refer to long strings: the server asks again once it read the piece
|
|
222
|
+
// A piece may itself refer to long strings: the server asks again once it read the piece,
|
|
223
|
+
// so what this chunk refers to is kept until the server stops asking.
|
|
223
224
|
for (let round = 0; round < 3; round++) {
|
|
224
225
|
if (answer?.snap) o.onSnap?.();
|
|
225
226
|
const need = (answer?.need || []).filter((h) => kept.has(h));
|
|
226
|
-
if (
|
|
227
|
-
if (!need.length) return;
|
|
227
|
+
if (!need.length) break;
|
|
228
228
|
for (const h of need) wanted.add(h);
|
|
229
229
|
const blobs: Record<string, string> = {};
|
|
230
230
|
for (const h of need) blobs[h] = kept.get(h) as string;
|
|
@@ -234,6 +234,7 @@ export function connect(o: ConnectOptions): Link {
|
|
|
234
234
|
kept.delete(h);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
+
for (const h of local.keys()) kept.delete(h);
|
|
237
238
|
}
|
|
238
239
|
|
|
239
240
|
/** The head of the page view, numbering again from 0 when it changed. */
|
package/src/testing/cases.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface Case {
|
|
|
19
19
|
readonly select?: ReadonlyArray<readonly [string, string]>;
|
|
20
20
|
/** Strings that must never leave the page, in clear. */
|
|
21
21
|
readonly secrets?: ReadonlyArray<string>;
|
|
22
|
+
/** What the browser must offer for the case to mean anything; skipped otherwise. */
|
|
23
|
+
readonly needs?: { readonly what: string; readonly test: (w: Window & typeof globalThis) => boolean };
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
const D = (body: string, head = "") =>
|
|
@@ -642,6 +644,7 @@ export const CASES: ReadonlyArray<Case> = [
|
|
|
642
644
|
{
|
|
643
645
|
name: "adoptedStyleSheets",
|
|
644
646
|
group: "styles",
|
|
647
|
+
needs: { what: "feuilles constructibles (Safari 16.4)", test: (w) => "adoptedStyleSheets" in w.Document.prototype },
|
|
645
648
|
html: D('<p class="a">a</p><div id="h"></div>'),
|
|
646
649
|
run: async (d, w, wait) => {
|
|
647
650
|
const s1 = new w.CSSStyleSheet();
|
package/src/testing/oracle.ts
CHANGED
|
@@ -80,6 +80,16 @@ export function compare(live: Document, copy: Document, o: OracleOptions = {}):
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
const cssAbs = (t: string) => t.replace(CSS_URL, (_m, _q, u: string) => `url("${abs(u)}")`);
|
|
83
|
+
// The player leaves out a name the copy's DOM refuses (`@click`, `:class` where the DOM still
|
|
84
|
+
// holds attribute names to the XML rules): that browser cannot hold it outside the parser.
|
|
85
|
+
const refused = (name: string) => {
|
|
86
|
+
try {
|
|
87
|
+
copy.createAttribute(name);
|
|
88
|
+
return false;
|
|
89
|
+
} catch {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
83
93
|
const rules = (sheet: CSSStyleSheet) => {
|
|
84
94
|
try {
|
|
85
95
|
return Array.from(sheet.cssRules, (r) => r.cssText).join("\n");
|
|
@@ -176,6 +186,7 @@ export function compare(live: Document, copy: Document, o: OracleOptions = {}):
|
|
|
176
186
|
})
|
|
177
187
|
.join(", ");
|
|
178
188
|
else if (name === "style" && side === "live") v = cssAbs(v);
|
|
189
|
+
if (side === "live" && refused(name)) continue;
|
|
179
190
|
m.set(name, v);
|
|
180
191
|
}
|
|
181
192
|
return m;
|