wasm-viewer tests: the cross-origin path without exposed headers
serve.py always exposed Content-Range and ETag, and Node has no CORS, so openUrl's documented cross-origin path (length from a HEAD request, answers checked by body length alone, no validator) was never run. - serve.py /noexpose/ serves ranges without Content-Range, ETag, Last-Modified or Accept-Ranges (what a page sees of a server that does not expose them); /unexposed/ sends them but exposes none, for a real browser. HEAD requests are counted (0 bytes). - test.mjs: every fixture check through /noexpose/ at 1 MiB and 512-byte blocks (one HEAD each, requests and bytes as the server counted them), concurrent reads with cacheSize 0, a short answer still caught, and a server without a HEAD length a clear error. - browser.sh: the page on 127.0.0.1 opens the file from localhost, once with Content-Range exposed and once through /unexposed/, where the server's log must show the HEAD. Checked by breaking the HEAD length in remote.js: the new checks fail. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -95,6 +95,20 @@ expect $H5 "/pairs" '<td>[2, 3]</td>' '<dd>array[2]<i32></dd>'
|
||||
expect $H5 "/cube" '<dd>(2, 5, 6)</dd>' '<td>29</td>' 'dim 0'
|
||||
# Unsupported type: an error, not values.
|
||||
expect $H5 "/table" 'class="error"' 'reading compound{x: f64, n: i32} datasets is not supported'
|
||||
# Cross-origin: the page is on 127.0.0.1, the file on localhost. CORS that
|
||||
# exposes Content-Range, and CORS that exposes nothing (/unexposed/: the
|
||||
# browser hides Content-Range and ETag, so the page learns the length with
|
||||
# a HEAD request, which the server's log must show).
|
||||
expect "http://localhost:$port/$H5" "/grid" '<td>14.75</td>' 'request'
|
||||
get() { "$PY" -c 'import sys, urllib.request; print(urllib.request.urlopen(sys.argv[1]).read().decode())' "$1"; }
|
||||
get "http://127.0.0.1:$port/__reset" >/dev/null
|
||||
expect "http://localhost:$port/unexposed/$H5" "/grid" '<td>0.25</td>' '<td>14.75</td>' 'request'
|
||||
heads="$(get "http://127.0.0.1:$port/__stats" | "$PY" -c \
|
||||
'import json, sys; print(sum(1 for l in json.load(sys.stdin)["log"] if l[4] == "HEAD" and l[0].endswith("fixture.h5")))')"
|
||||
if [ "$heads" -lt 1 ]; then
|
||||
echo "FAIL: no HEAD request for the length with unexposed headers" >&2
|
||||
fails=$((fails + 1))
|
||||
fi
|
||||
# A server without range support: the file is downloaded whole, and says so.
|
||||
expect norange/$H5 "/grid" '<td>14.75</td>' 'downloaded whole'
|
||||
# A large file: a small dataset, and a window of the large one, fetch a few
|
||||
|
||||
Reference in New Issue
Block a user