-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
387 lines (345 loc) · 15.4 KB
/
index.html
File metadata and controls
387 lines (345 loc) · 15.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>graphdiff.js tester</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="./styles.css">
<style>
.tags-host { display:flex; gap:.5rem; flex-wrap:wrap; margin:.25rem 0 0 }
.tag-chip { display:inline-block; padding:.15rem .5rem; border-radius:999px; font-size:.75rem; line-height:1.2; background:#eef; color:#223; border:1px solid #cdd; }
/*sandbox*/
.sandbox-wrap{margin-top:.75rem; border:1px solid #8884; border-radius:.5rem; padding:.75rem;}
.sandbox-actions{display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin:.25rem 0 .5rem;}
.sandbox-row{display:grid; grid-template-columns:1fr auto; gap:.5rem; align-items:center; margin:.5rem 0;}
.sandbox-row textarea{width:100%; height:160px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace; font-size:12px; padding:.6rem .8rem; border-radius:.6rem; border:1px solid #8884; background: rgba(255,255,255,.04);}
.snippet-kind{font-size:12px; opacity:.8;}
</style>
</head>
<body>
<main class="container">
<h1>graphdiff.js tester</h1>
<!--run-->
<section class="controls">
<div class="control">
<label for="inclusion">Inclusion method</label>
<!-- values map to files in /inclusionmethods/ -->
<select id="inclusion">
<!-- common put first-->
<option selected>iframe.html</option>
<option>audio.html</option>
<option>image.html</option>
<option>video.html</option>
<option>script.html</option>
<option>stylesheet.html</option>
<option>fetch.html</option>
<option>import.html</option>
<option>object.html</option>
<!-- full list -->
<option>embed.html</option>
<option>embedhashreload.html</option>
<option>eventsource.html</option>
<option>favicon.html</option>
<option>fetchall.html</option>
<option>fetchcors.html</option>
<option>fetchcorscredless.html</option>
<option>formactioncsp.html</option>
<option>frame.html</option>
<option>iframecsp.html</option>
<option>iframecspreload.html</option>
<option>iframehashreload.html</option>
<option>iframesandbox.html</option>
<option>importscript.html</option>
<option>linkmanifest.html</option>
<option>linkprefetch.html</option>
<option>objecthashreload.html</option>
<option>preloadscript.html</option>
<option>preloadstyle.html</option>
<option>prerender.html</option>
<option>svg.html</option>
<option>track.html</option>
<option>websocket.html</option>
<option>windowopen.html</option>
</select>
</div>
<div class="control">
<label for="filetype">File type</label>
<!-- values map to files in /filetemplates/ -->
<select id="filetype">
<option selected>test.gif</option>
<option>test.html</option>
<option>test.js</option>
<option>test.json</option>
<option>test.txt</option>
<option>test.wav</option>
<option>iframe.html</option>
<option>input.html</option>
<option>test.css</option>
<option>test.empty</option>
<option>test.pdf</option>
</select>
</div>
<div class="control">
<!--these are all merged from testconfigs/*, i put them alphabetically-->
<label for="difference">Difference (merged from testconfigs/*)</label>
<select id="difference"></select>
</div>
<div class="control" style="display:flex; gap:.5rem; align-items:center;">
<button id="run">Run</button>
<button id="copy-link" class="btn btn-secondary" type="button" title="Copy a shareable link for this test">Copy test link</button>
<span id="copy-toast" class="meta" style="display:none;">Link copied</span>
</div>
</section>
<section id="downloads" class="downloads hidden">
<h2>Latest Downloads (last run)</h2>
<div class="row">
<a id="dl0" download class="btn disabled">State 0 JSON</a>
<a id="dl1" download class="btn disabled">State 1 JSON</a>
</div>
</section>
<details class="advanced">
<summary>Advanced</summary>
<label><input type="checkbox" id="autoclose" checked> Auto-close popups when result captured</label>
<label><input type="checkbox" id="bust" checked> Cache-bust resource URLs</label>
<!-- blocklist toggle -->
<div style="margin-top:0.5rem">
<label><input type="checkbox" id="applyBlocklist"> Apply default blocklist to hide noisy differences</label>
<div class="note">By default the UI shows <strong>all</strong> differences. Check this to hide noisy URL/ownerDocument/VEE differences using the built-in blocklist.</div>
</div>
<div style="margin-top:0.5rem">
<label><input type="checkbox" id="windowMode"> Open crawler as regular windows instead of small popups</label>
</div>
<!-- SANDBOX -->
<div id="sandbox" class="sandbox-wrap">
<div class="sandbox-actions">
<button id="sandbox-open" type="button" class="btn btn-primary">Open two sandbox windows</button>
<button id="sandbox-paste0" type="button" class="btn btn-secondary" title="If messaging is blocked, paste JSON captured in Window A">Paste JSON -> State 0</button>
<button id="sandbox-paste1" type="button" class="btn btn-secondary" title="If messaging is blocked, paste JSON captured in Window B">Paste JSON -> State 1</button>
<span id="sandbox-status" class="meta">Open each window, navigate to your pages, open DevTools -> Console, paste the Vendor crawler snippet for State 0/1. The graphs will appear here; diffing starts when both are ready.</span>
</div>
<div class="sandbox-row">
<div>
<div class="snippet-kind">Vendor crawler - Window A (State 0)</div>
<textarea id="sandbox-s0-vendor" readonly></textarea>
</div>
<div><button id="sandbox-copy0-vendor" type="button" class="btn btn-secondary">Copy</button></div>
</div>
<div class="sandbox-row">
<div>
<div class="snippet-kind">Vendor crawler - Window B (State 1)</div>
<textarea id="sandbox-s1-vendor" readonly></textarea>
</div>
<div><button id="sandbox-copy1-vendor" type="button" class="btn btn-secondary">Copy</button></div>
</div>
</div>
<pre id="diffPreview" class="pre"></pre>
</details>
<hr style="margin:2rem 0">
<!--results-->
<section id="results" class="results-shell list-mode">
<div class="results-header">
<h2>Results</h2>
<div class="results-actions">
<input id="case-search" type="search" placeholder="Search runs…" autocomplete="off">
<button id="open-filters" class="btn btn-secondary" type="button">Filters</button>
<button id="back-to-list" class="btn btn-secondary back-btn" type="button">← Back to test cases</button>
</div>
</div>
<!-- LIST VIEW -->
<div id="list-view" class="list-view">
<table id="cases-table" class="cases-table">
<thead>
<tr>
<th>Inclusion</th>
<th>File</th>
<th>Difference</th>
<th># Diffs</th>
<th>Tags</th>
</tr>
</thead>
<tbody>
<!-- rows from JS -->
</tbody>
</table>
<div id="cases-empty" class="cases-empty">No runs yet. Click “Run”.</div>
</div>
<!-- DETAIL VIEW (this is what app.js fills into #tabs/#panels) -->
<div id="detail-view" class="detail-view">
<div class="detail-toolbar">
<div id="detail-title" class="detail-title"></div>
<div class="detail-tools">
<div class="detail-filter">
<select id="detail-field" title="Filter field">
<option value="all">All fields</option>
<option value="path">Path</option>
<option value="s0">State 0</option>
<option value="s1">State 1</option>
</select>
<input id="detail-search" type="search" placeholder="Filter rows in this run…" autocomplete="off">
<button id="detail-clear" class="btn btn-ghost" type="button">Clear</button>
</div>
<div id="detail-count" class="detail-count"></div>
</div>
</div>
<!-- inline spinner while a test-case is being computed -->
<div id="detail-spinner" class="spinner-row" aria-hidden="true">
<div class="spinner" role="status" aria-label="Loading"></div>
<span>Computing differences…</span>
</div>
<!-- reminder keep these because app.js writes into them -->
<div id="tabs" class="tabs"></div>
<div id="panels" class="tabpanels"></div>
</div>
</section>
</main>
<!-- filter drawer -->
<div id="filter-modal" class="filter-modal" aria-hidden="true">
<div class="filter-backdrop" data-close="1"></div>
<div class="filter-sheet" role="dialog" aria-modal="true" aria-labelledby="filter-title">
<div class="filter-header">
<h3 id="filter-title">Filter runs</h3>
<button type="button" class="filter-close" data-close="1" aria-label="Close filters">×</button>
</div>
<div class="filter-body">
<div class="filter-group">
<label for="filter-inclusion">Inclusion method</label>
<select id="filter-inclusion">
<option value="__all__">All</option>
</select>
</div>
<div class="filter-group">
<label for="filter-file">File</label>
<select id="filter-file">
<option value="__all__">All</option>
</select>
</div>
<div class="filter-group">
<label for="filter-diff">Difference</label>
<select id="filter-diff">
<option value="__all__">All</option>
</select>
</div>
<div class="filter-group">
<div class="filter-group-header">
<span>Tags</span>
<button id="filter-tags-all" type="button" class="link-btn">Select all</button>
<button id="filter-tags-none" type="button" class="link-btn">Clear</button>
</div>
<div id="filter-tags-host" class="filter-tags-host">
<!-- checkboxes inserted from JS -->
</div>
</div>
</div>
<div class="filter-footer">
<button id="filter-apply" class="btn btn-primary" type="button">Apply filters</button>
<button data-close="1" class="btn btn-ghost" type="button">Close</button>
</div>
</div>
</div>
<script type="module" src="./app.js"></script>
<script type="module" src="./results-ui.js"></script>
<script type="module" src="./permalink.js"></script>
<!-- fix, diff preview should reflect the currently selected difference -->
<script>
(function(){
const TESTCONFIG_FILES = [
'config.json','csv-export.json','default.json','top200-500.json',
'top200.json','veryhax_test.json','wpt-header.json',
];
const map = new Map();
async function loadAll() {
for (const f of TESTCONFIG_FILES) {
try {
const res = await fetch(`./testconfigs/${f}`, { cache: 'no-store' });
if (!res.ok) continue;
const j = await res.json();
if (Array.isArray(j.differences)) {
for (const d of j.differences) {
if (d && d.name) map.set(d.name, d);
}
}
} catch {}
}
}
function updatePreview() {
const sel = document.getElementById('difference');
const pre = document.getElementById('diffPreview');
if (!sel || !pre) return;
const name = sel.value;
const obj = map.get(name);
if (obj) pre.textContent = JSON.stringify(obj, null, 2);
}
function wireSelectObserver() {
const sel = document.getElementById('difference');
if (!sel) return;
sel.addEventListener('change', updatePreview);
//when app.js fills options asynchronously, reflect the selected value
const mo = new MutationObserver(updatePreview);
mo.observe(sel, { childList: true });
updatePreview();
}
(async () => {
await loadAll();
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', wireSelectObserver, { once: true });
} else {
wireSelectObserver();
}
})();
})();
</script>
<!--show a spinner in the "# Diffs" column while a run is being computed -->
<script>
(function(){
const tabs = document.getElementById('tabs');
const tbody = document.querySelector('#cases-table tbody');
const empty = document.getElementById('cases-empty');
if (!tabs || !tbody) return;
function baseLabelExcludingSmall(btn){
let s = '';
btn.childNodes.forEach(n => {
if (n.nodeType === Node.TEXT_NODE) s += n.textContent;
else if (n.nodeType === 1 && !n.classList.contains('small')) s += n.textContent;
});
return s.trim();
}
function ensurePendingRowFromTab(btn){
if (!btn || !btn.id || !btn.id.startsWith('tab-')) return;
const sid = btn.id.slice(4);
//parse label "inc | file | diff" (exclude the .small status span)
let label = baseLabelExcludingSmall(btn);
const parts = label.split('|').map(s => s.trim());
const inclusion = parts[0] || '';
const file = parts[1] || '';
const diff = parts[2] || '';
// if a row for this sid already exists (either pending or real), skip
if (tbody.querySelector(`tr[data-sid="${sid}"]`)) return;
const tr = document.createElement('tr');
tr.className = 'pending-row';
tr.dataset.sid = sid;
tr.innerHTML = `
<td>${inclusion}</td>
<td>${file}</td>
<td>${diff}</td>
<td><span class="diff-loading" aria-label="Calculating…"><b class="d1"></b><b class="d2"></b><b class="d3"></b></span></td>
<td><span class="tag-badge">pending</span></td>
`;
tbody.appendChild(tr);
if (empty) empty.style.display = 'none';
}
const mo = new MutationObserver(muts => {
for (const m of muts) {
m.addedNodes && m.addedNodes.forEach(n => {
if (n.nodeType === 1 && n.matches && n.matches('button.tab')) ensurePendingRowFromTab(n);
if (n.nodeType === 1) {
const btns = n.querySelectorAll ? n.querySelectorAll('button.tab') : [];
btns.forEach(ensurePendingRowFromTab);
}
});
}
});
mo.observe(tabs, { childList: true, subtree: true });
})();
</script>
</body>
</html>