Skip to content

Commit

Permalink
StarlingMonkey WPT tests (#810)
Browse files Browse the repository at this point in the history
Co-authored-by: Trevor Elliott <[email protected]>
  • Loading branch information
guybedford and elliottt authored Jun 24, 2024
1 parent 7bd1580 commit e621dc9
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/starlingmonkey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
if: steps.cache-crate.outputs.cache-hit != 'true'

run_wpt:
if: github.ref != 'refs/heads/main' && false
if: github.ref != 'refs/heads/main'
name: Run Web Platform Tests
needs: [build, ensure_cargo_installs]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
- name: Run tests
timeout-minutes: 20
run: node ./tests/wpt-harness/run-wpt.mjs --starlingmonkey -vv
run: node ./tests/wpt-harness/run-wpt.mjs -vv

sdktest:
if: github.ref != 'refs/heads/main'
Expand Down
2 changes: 1 addition & 1 deletion runtime/StarlingMonkey
4 changes: 1 addition & 3 deletions runtime/fastly/builtins/fetch/request-response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2879,9 +2879,7 @@ bool Response::constructor(JSContext *cx, unsigned argc, JS::Value *vp) {
return false;
}
if (!statusText_val.isUndefined()) {
auto statusText_str = core::encode(cx, statusText_val);
std::string s(statusText_str.ptr.get(), statusText_str.len);
auto status_text_result = convertJSValueToByteString(cx, s);
auto status_text_result = convertJSValueToByteString(cx, statusText_val);
if (status_text_result.isErr()) {
JS_ReportErrorNumberASCII(cx, FastlyGetErrorMessage, nullptr,
JSMSG_RESPONSE_CONSTRUCTOR_INVALID_STATUS_TEXT);
Expand Down
7 changes: 5 additions & 2 deletions runtime/fastly/handler.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "../StarlingMonkey/builtins/web/performance.h"
#include "./builtins/fetch-event.h"
#include "./host-api/fastly.h"
#include "./host-api/host_api_fastly.h"
Expand All @@ -14,14 +15,16 @@ namespace fastly::runtime {

api::Engine *ENGINE;

// Install corresponds to Wizer time, so we configure the engine here
bool install(api::Engine *engine) {
ENGINE = engine;
engine->enable_module_mode(false);
return true;
}

void handle_incoming(host_api::Request req) {
// TODO(GB): reimplement
// builtins::Performance::timeOrigin.emplace(std::chrono::high_resolution_clock::now());
builtins::web::performance::Performance::timeOrigin.emplace(
std::chrono::high_resolution_clock::now());

double total_compute = 0;
auto start = system_clock::now();
Expand Down
18 changes: 10 additions & 8 deletions runtime/fastly/host-api/host_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ void sleep_until(uint64_t time_ns, uint64_t now) {
}
}

size_t api::AsyncTask::select(std::vector<api::AsyncTask *> *tasks) {
size_t tasks_len = tasks->size();
size_t api::AsyncTask::select(std::vector<api::AsyncTask *> &tasks) {
size_t tasks_len = tasks.size();
std::vector<fastly_compute_at_edge_async_io_handle_t> handles;
handles.reserve(tasks_len);
uint64_t now = 0;
uint64_t soonest_deadline = 0;
size_t soonest_deadline_idx = -1;
for (size_t idx = 0; idx < tasks_len; ++idx) {
auto *task = tasks->at(idx);
auto *task = tasks.at(idx);
uint64_t deadline = task->deadline();
// Select for completed task deadlines before performing the task select host call.
if (deadline > 0) {
Expand Down Expand Up @@ -86,7 +86,7 @@ size_t api::AsyncTask::select(std::vector<api::AsyncTask *> *tasks) {
// non-timer task.
size_t task_idx = 0;
for (size_t idx = 0; idx < tasks_len; ++idx) {
if (tasks->at(idx)->id() != NEVER_HANDLE) {
if (tasks.at(idx)->id() != NEVER_HANDLE) {
if (ret.val == task_idx) {
return idx;
}
Expand Down Expand Up @@ -1819,11 +1819,13 @@ const std::optional<std::string> FastlySendError::message() const {
/// The system encountered a DNS error when trying to find an IP address for the backend
/// hostname. The fields dns_error_rcode and dns_error_info_code may be set in the
/// send_error_detail.
// TODO(GB): reenable DNS error codes
case dns_error: {
return "DNS error (rcode={}, info_code={})" /*, this->dns_error_rcode,
this->dns_error_info_code*/
;
// allocate maximum len of error message
char buf[34 + 10 + 1];
int written = snprintf(buf, sizeof(buf), "DNS error (rcode=%d, info_code=%d)",
this->dns_error_rcode, this->dns_error_info_code);
MOZ_ASSERT(written > 34);
return std::string(buf, written);
}
/// The system cannot determine which backend to use, or the specified backend was invalid.
case destination_not_found: {
Expand Down
12 changes: 6 additions & 6 deletions runtime/js-compute-runtime/rust-url/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion runtime/js-compute-runtime/rust-url/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
crate-type = ["staticlib"]

[dependencies]
url = "2.5.0"
url = "2.5.2"

[profile.release]
lto = true
Expand Down
2 changes: 1 addition & 1 deletion tests/wpt-harness/expectations/url/url-setters.any.js.json
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@
"status": "PASS"
},
"URL: Setting <foo://somehost/some/path>.pathname = '' Non-special URLs can have their paths erased": {
"status": "FAIL"
"status": "PASS"
},
"URL: Setting <foo:///some/path>.pathname = '' Non-special URLs with an empty host can have their paths erased": {
"status": "FAIL"
Expand Down

0 comments on commit e621dc9

Please sign in to comment.