mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 19:19:30 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
48
Libraries/LibJS/Contrib/Test262/AgentObject.cpp
Normal file
48
Libraries/LibJS/Contrib/Test262/AgentObject.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Time.h>
|
||||
#include <LibJS/Contrib/Test262/AgentObject.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace JS::Test262 {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AgentObject);
|
||||
|
||||
AgentObject::AgentObject(Realm& realm)
|
||||
: Object(Object::ConstructWithoutPrototypeTag::Tag, realm)
|
||||
{
|
||||
}
|
||||
|
||||
void AgentObject::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, "monotonicNow", monotonic_now, 0, attr);
|
||||
define_native_function(realm, "sleep", sleep, 1, attr);
|
||||
// TODO: broadcast
|
||||
// TODO: getReport
|
||||
// TODO: start
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(AgentObject::monotonic_now)
|
||||
{
|
||||
auto time = MonotonicTime::now();
|
||||
auto milliseconds = time.milliseconds();
|
||||
return Value(static_cast<double>(milliseconds));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(AgentObject::sleep)
|
||||
{
|
||||
auto milliseconds = TRY(vm.argument(0).to_i32(vm));
|
||||
::usleep(milliseconds * 1000);
|
||||
return js_undefined();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue