mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibJS: Skip test262 tests with the CanBlockIsFalse flag
From test262 documentation, this flag means: The test file should only be run when the [[CanBlock]] property of the Agent Record executing the file is `false`. This patch stubs out the accessor for that internal slot and skips tests with the CanBlockIsFalse if that internal slot is true.
This commit is contained in:
parent
a7ff65a0c6
commit
a7073c3f1f
Notes:
sideshowbarker
2024-07-18 08:59:31 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/a7073c3f1f Pull-request: https://github.com/SerenityOS/serenity/pull/21951 Reviewed-by: https://github.com/awesomekling ✅ Reviewed-by: https://github.com/shannonbooth ✅
5 changed files with 49 additions and 0 deletions
|
@ -58,6 +58,7 @@ shared_library("LibJS") {
|
|||
"ParserError.cpp",
|
||||
"Print.cpp",
|
||||
"Runtime/AbstractOperations.cpp",
|
||||
"Runtime/Agent.cpp",
|
||||
"Runtime/AggregateError.cpp",
|
||||
"Runtime/AggregateErrorConstructor.cpp",
|
||||
"Runtime/AggregateErrorPrototype.cpp",
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <LibJS/Bytecode/Interpreter.h>
|
||||
#include <LibJS/Contrib/Test262/GlobalObject.h>
|
||||
#include <LibJS/Parser.h>
|
||||
#include <LibJS/Runtime/Agent.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibJS/Runtime/ValueInlines.h>
|
||||
#include <LibJS/Script.h>
|
||||
|
@ -169,6 +170,11 @@ enum class StrictMode {
|
|||
OnlyStrict
|
||||
};
|
||||
|
||||
enum class SkipTest {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
|
||||
static constexpr auto sta_harness_file = "sta.js"sv;
|
||||
static constexpr auto assert_harness_file = "assert.js"sv;
|
||||
static constexpr auto async_include = "doneprintHandle.js"sv;
|
||||
|
@ -176,6 +182,8 @@ static constexpr auto async_include = "doneprintHandle.js"sv;
|
|||
struct TestMetadata {
|
||||
Vector<StringView> harness_files { sta_harness_file, assert_harness_file };
|
||||
|
||||
SkipTest skip_test { SkipTest::No };
|
||||
|
||||
StrictMode strict_mode { StrictMode::Both };
|
||||
JS::Program::Type program_type { JS::Program::Type::Script };
|
||||
bool is_async { false };
|
||||
|
@ -364,6 +372,9 @@ static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source
|
|||
} else if (flag == "async"sv) {
|
||||
metadata.harness_files.append(async_include);
|
||||
metadata.is_async = true;
|
||||
} else if (flag == "CanBlockIsFalse"sv) {
|
||||
if (JS::agent_can_suspend())
|
||||
metadata.skip_test = SkipTest::Yes;
|
||||
}
|
||||
}
|
||||
} else if (line.starts_with("includes:"sv)) {
|
||||
|
@ -733,6 +744,10 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
auto& metadata = metadata_or_error.value();
|
||||
if (metadata.skip_test == SkipTest::Yes) {
|
||||
result_object.set("result", "skipped");
|
||||
continue;
|
||||
}
|
||||
|
||||
bool passed = true;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ set(SOURCES
|
|||
Print.cpp
|
||||
Runtime/AbstractOperations.cpp
|
||||
Runtime/Accessor.cpp
|
||||
Runtime/Agent.cpp
|
||||
Runtime/AggregateError.cpp
|
||||
Runtime/AggregateErrorConstructor.cpp
|
||||
Runtime/AggregateErrorPrototype.cpp
|
||||
|
|
19
Userland/Libraries/LibJS/Runtime/Agent.cpp
Normal file
19
Userland/Libraries/LibJS/Runtime/Agent.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Agent.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
// 9.7.2 AgentCanSuspend ( ), https://tc39.es/ecma262/#sec-agentcansuspend
|
||||
bool agent_can_suspend()
|
||||
{
|
||||
// FIXME: 1. Let AR be the Agent Record of the surrounding agent.
|
||||
// FIXME: 2. Return AR.[[CanBlock]].
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
13
Userland/Libraries/LibJS/Runtime/Agent.h
Normal file
13
Userland/Libraries/LibJS/Runtime/Agent.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace JS {
|
||||
|
||||
bool agent_can_suspend();
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue