这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Prior to this, it hadn't been possible to run an up-to-date version of test262 i

You can either provide a local .zip of the repo (with or without .git/), or click 'Remote' to load the one hosted in this repository.

The hosted copy was last updated on 05 November, 2018.
The hosted copy was last updated on 11 March, 2025.

A version allowing preprocessing of tests, intended for tool authors, is available [here](https://bakkot.github.io/test262-web-runner/transformed.html).

Running this locally using cross origin isolation is possible using `python cross-origin-http.py`. This allows Shared Array Buffer tests to work as expected.

17 changes: 17 additions & 0 deletions cross-origin-http.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to commit this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. Sorry i didn't explain: Its a bit of a pain to test SAB without a file like this, so if you want to start a cross origin isolated version of this repo you can run python3 cross-origin-http.py and it will do it for you. I can add a readme? Forgot to do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(was the original reason i forked and started mucking about)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A sentence or two in the readme would be great, yeah.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember I'll try to add my standard fix for this, which is a service worker to inject the necessary headers (so that it can still be done on Github Pages instead of needing the local server). But no promises on timeline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh thats a nice way to do it. Well -- i can add the readme change for now and when you've got time for something more elegant you can just remove this file and the line?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, thanks!

from http.server import HTTPServer, SimpleHTTPRequestHandler
import sys

class CustomRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')
self.send_header('Cross-Origin-Opener-Policy', 'same-origin')
return super(CustomRequestHandler, self).end_headers()

host = sys.argv[1] if len(sys.argv) > 2 else '0.0.0.0'
port = int(sys.argv[len(sys.argv)-1]) if len(sys.argv) > 1 else 8000

print("Listening on {}:{}".format(host, port))
print("Connect to http://localhost:{}/ for cross-origin isolation".format(port))
httpd = HTTPServer((host, port), CustomRequestHandler)
httpd.serve_forever()
14 changes: 12 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ function loadUnit(path) {
return function(then, error) {
return function(task) {
var file = path.reduce(function(acc, name) { return acc.files[name]; }, tree).file;
file.async("string").then(function(c) { then(task, c); }, function(e) { error(task); });
if (file) {
file.async("string").then(function(c) { then(task, c); }, function(e) { error(task); });
} else {
then();
}
};
};
}
Expand Down Expand Up @@ -708,6 +712,9 @@ function loadZip(z) {
var renderPromise = new Promise(function(_resolve, _reject) { resolve = _resolve; reject = _reject; });
var harnessNames = Object.keys(tree.files.harness.files);
loadAllUnqueued(harnessNames.map(function(include) { return ['harness', include]; }), function(harnessFiles) {
if (!harnessFiles) {
resolve();
}
try {
for (var i = 0; i < harnessNames.length; ++i) {
harness[harnessNames[i]] = harnessFiles[i];
Expand Down Expand Up @@ -778,7 +785,10 @@ window.addEventListener('load', function() {
loadStatus.style.display = 'inline-block';
loadZip(file)
.then(function() { loadStatus.innerHTML = 'Loaded <kbd>' + safeSrc + '</kbd>.'; })
.catch(function(e) { loadStatus.textContent = e; })
.catch(function(e) {
console.log(e)
loadStatus.textContent = e;
})
.then(function() { fileEle.value = ''; });
});

Expand Down