Commit graph

125 commits

Author SHA1 Message Date
Auguste Baum
9654363c18
script: Start replacing time with std::time and chrono (#30639)
* Replace `time` with `chrono` in `script/animation_timeline`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `std::time` in `script/script_thread.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `std::time` and `chrono` in `script/script_thread.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `std::time` in `script/script_runtime.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `std::time` in `script/script_runtime.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `std::time` in `script/dom/workerglobalscope.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `chrono` in `script/dom/workerglobalscope.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `std::time` in `script/dom/htmlmedialelement.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `std::time` in `script/dom/htmlmedialelement.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `std::time` in `script/dom/globalscope.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `chrono` in `script/dom/globalscope.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `std::time` in `script/dom/htmlformelement.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Replace `time` with `std::time` in `script/dom/htmlformelement.rs`

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>

* Increase precision of animation timeline

* Some fixes

Use Instant a bit more and stop using chrono. Do not transition
`navigation_start_precise` to Instant yet as we need to coordinate this
across all crates.

---------

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-01-16 12:23:18 +00:00
Samson
604979e367
Replace script_plugins with a clippy like rustc driver (named crown) (#30508)
* Remove script_plugins

* Use crown instead of script_plugins

* crown_is_not_used

* Use crown in command base

* bootstrap crown

* tidy happy

* disable sccache

* Bring crown in tree

* Install crown from tree

* fix windows ci

* fix warning

* fix mac

libscript_plugins.dylib is not available anymore

* Update components/script/lib.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

* Update for nightly-2023-03-18

Mostly just based off https://github.com/servo/servo/pull/30630

* Always install crown

it's slow only when there is new version

* Run crown test with `mach test-unit`

* Small fixups; better trace_in_no_trace tests

* Better doc

* crown in config.toml

* Fix tidy for real

* no sccache on rustc_wrapper

* document rustc overrides

* fixup of compiletest

* Make a few minor comment adjustments

* Fix a typo in python/servo/platform/base.py

Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com>

* Proper test types

* Ignore tidy on crown/tests

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2023-12-01 15:50:52 +00:00
Samson
ebd41d4101
Use Foo_Binding instead of FooBinding for namespace modules (#30447)
* Update Codegen.py to emit Foo_Binding instead of FooBinding

* s/FooBinding/Foo_Binding/g
2023-09-30 00:52:04 +00:00
Samson
aad2dccc9c
Strict import formatting (grouping and granularity) (#30325)
* strict imports formatting

* Reformat all imports
2023-09-11 19:16:54 +00:00
Samson
59d134133f
Use MozTools 4 and update mozjs (#30326)
* Update mozjs

* moztools4 in bootstrap

* no autoconf

* tidy

* switch to servo-build-deps

* update mozjs for real

* glue mozjs

* fmt

* move to servo/mozjs
2023-09-11 08:23:05 +00:00
Samson
711dbbd4af
remove extern crate (#30311)
* remove extern crate

* Update components/script_plugins/lib.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2023-09-08 12:11:31 +00:00
Samson
450f8193a5
Use mozjs tracing infrastructure (#29918)
* Update mozjs

64711ec2e6 also fixes https://github.com/servo/servo/issues/30043

* Move to mozjs Traceable and introduce CustomTraceable
2023-08-10 21:46:06 +00:00
Mukilan Thiyagarajan
5305c507c2
Fix race condition and other issues related to Worker destruction. (#30066)
* Fix race condition in Worker destruction

During shutdown, the main script thread calls
JS_RequestInterruptCallback(cx) for each worker thread it owns
where cx is the JSContext* created for that worker.
Although JS_RequestInterruptCallback is safe to call
from threads other than the worker thread, it is possible
the JSContext* has already been destroyed

For example, as noted in #30022, since the main thread sets
the worker's `closing` flag to true to signal termination before it
calls JS_RequestInterruptCallback, we can have a race condition
where the worker exits its event loop when `closing` flags is set
and then it (worker thread) destroys its own JSContext and JSRuntime.
When the main thread resumes, it will call
JS_RequestInterruptCallback for the worker's context, leading to
a use-after-free bug.

This patch solves this issue by improving the existing
`ContextForRequestInterrupt` abstraction used for sharing the Worker's
associated JSContext* with the parent script thread.
Instead of simply wrapping a plain `*mut JSContext`, we now wrap the
`*mut JSContext` in a nullable mutex i.e Mutex<Option<*mut JSContext>>

The mutex lock needs to be held by the parent thread when it
calls JS_RequestInterruptCallback.
Similary, before the worker destroys its JSContext, it locks and
sets the Option to None, signaling that the JSContext can no longer
be used for interrupting the worker.

This patch also fixes the issue in #30052 by enforcing the use
of ContextForRequestInterrupt abstraction which ensures the correct
JSContext is used by the main thread when Worker.terminate is called.

Fixes #30022, #30052

* Fix Worker.importScripts to handle termination

Fixing #30052 uncovered this issue in the implementation
of `importScripts` method. After the fix for #30052,
the WPT test `/workers/Worker-terminate-forever-during-evaluation.html`
started to crash because when evaluation doesn't succeed
`importScripts` always returns Error::JSFailed code to the caller,
which indicates that there is a Dom/JS exception to be thrown. However,
this is not true when the script is terminated, which causes
the generated binding layer for 'importScript` to fail
the assertion that there is a pending exception.

This patch makes `importScripts` work similar to the [logic that
evaluates the top-level script][1] of the Worker - it simply prints
`evaluate_script failed - (terminated)' if the worker is terminating

[1]: 3fea90a231/components/script/dom/workerglobalscope.rs (L434)
2023-08-03 23:33:21 +00:00
Josh Matthews
f79e1e327d Make GlobalScope.get_cx a static method. 2023-05-20 11:05:09 -04:00
Martin Robinson
dc192172ad Clean up debug options 2023-05-01 14:09:28 +02:00
Josh Matthews
f76bb20c2e Format. 2022-11-23 10:04:53 -05:00
Josh Matthews
bd77a4043c Changes for spidermomkey upgrade. 2022-11-23 10:04:50 -05:00
yvt
320965bfb9 refactor(script): move crate::dom::bindings::{utils → principals)::ServoJSPrincipal 2021-07-13 21:45:21 +09:00
yvt
2f3a14b491 doc(script): prettify a comment 2021-07-12 01:07:30 +09:00
yvt
40fbe6b722 chore(deps): update mozjs
- 798c5b6: Bring `RustJSPrincipals` back
2021-07-11 23:01:21 +09:00
yvt
28c670d6c3 fix: accommodate to the modern age 2021-07-10 18:18:33 +09:00
yvt
01a7de50ab Merge remote-tracking branch 'upstream/master' into feat-cow-infra
`tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html`
was reverted to the upstream version.
2021-07-10 17:55:42 +09:00
sagudev
a265a2a7e6 Formating 2021-03-12 18:30:13 +01:00
sagudev
425057c432 Fix errors 2021-03-12 16:26:27 +01:00
Josh Matthews
5c4939599e Update mozjs. 2021-02-18 09:35:45 -05:00
Gregory Terzian
44ebca72da ensure clean shutdown of all threads running JS 2020-06-30 13:22:38 +08:00
bors-servo
6d9b2eef29
Auto merge of #26943 - jdm:promise-incumbent, r=Manishearth
Fix panic on vimeo.com

The only time we end up enqueuing a promise reaction job with a null incumbent global argument is when SpiderMonkey does some weird stuff behind the scenes for its JS Debugger support (based on https://searchfox.org/mozilla-central/rev/2c1092dc68c63f7bad6da6a03c5883a5ab5ff2ca/js/src/builtin/Promise.cpp#3168). This commit works around that case and adds a regression test so we don't forget about that in the future.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #26930
- [x] There are tests for these changes
2020-06-16 20:03:28 -04:00
Josh Matthews
2e4cee9971 dom: Avoid panic when SpiderMonkey enqueues dummy promise jobs. 2020-06-16 17:21:18 -04:00
Josh Matthews
83578265b4 Don't pretend we support SharedArrayBuffer. 2020-06-16 14:39:20 -04:00
Gregory Terzian
bd5796c90b integrate readablestream with fetch and blob 2020-06-04 11:38:35 +08:00
Simon Sapin
d103e06ba9 Use dynamic dispatch in mozjs::panic::wrap_panic
Pick up https://github.com/servo/rust-mozjs/pull/512

Fixes https://github.com/servo/servo/issues/26585

This diff is best viewed with "ignore whitespace changes", because of indentation change.
2020-05-25 20:34:05 +02:00
Kunal Mohan
39f336b527 Implement client-side logic for WebGPU id recycling 2020-05-22 21:22:19 +05:30
Alan Jeffrey
c611e46381 Remove WebVR 2020-04-08 20:23:41 -05:00
bors-servo
fd6f9140f7
Auto merge of #26056 - gterzian:enable_atomics_wait_on_dedicated_worker, r=jdm
Enable Atomics.wait in a dedicated worker agent

<!-- Please describe your changes on the following line: -->

FIX #25191

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2020-03-30 10:42:23 -04:00
Gregory Terzian
3ce6109836 enable Atomics.wait in a dedicated worker agent 2020-03-30 15:23:04 +08:00
Paul Rouget
5621c887fd Propagate user interacting flag to timers and promises 2020-03-26 08:36:57 +01:00
Anthony Ramine
5a4f8cf93f Update SpiderMonkey 2020-03-06 11:13:28 +01:00
CYBAI
403ffcf1eb Always pass InRealm to GlobalScope::from_context to avoid getting null global 2020-02-16 09:55:10 +09:00
Kunal Mohan
f7db4b7f80
Modify script to prevent further violations of snake_case 2020-01-18 14:22:15 +05:30
CYBAI
f2007751dd Scaffold module script 2020-01-03 13:02:31 +09:00
Patrick Shaughnessy
1506643f9a Now using eq_ignore_case on WASM mimetype, per #25317 2019-12-31 18:26:45 -05:00
Ridhim Rastogi
a5469f8710 Add StreamConsumer wrapper and methods to response 2019-12-03 15:59:35 -05:00
Josh Matthews
1c7f2d696c Remove use of deprecated language construct. 2019-11-26 21:54:33 -05:00
Josh Matthews
7944d9548c script: Ensure JS engine is initialized and deinitialized on the same thread. 2019-11-26 21:54:33 -05:00
Akash-Pateria
84f16eae98 Bind runnable dispatching in script_runtime 2019-11-19 23:25:52 -05:00
Ridhim Rastogi
563961826f Add consume stream callback 2019-11-11 16:48:52 -05:00
Ridhim Rastogi
9fb01e879b Add StreamConsumer wrapper and ReportStreamErrorCallback fn 2019-11-03 03:41:41 -05:00
Keith Yeung
c3b17c1201 begin messageport, transferable objects, impl
Accept transfer argument for StructuredCloneData::write

Allow structured clone reads to return a boolean

Add Transferable trait

Add basic skeletons to MessagePort

Implement transfer and transfer-receiving steps on MessagePort

Use transfer and transfer_receive in StructuredClone callbacks

Implement MessageChannel

Freeze the array object for the MessageEvent ports attribute

Implement transfer argument on window.postMessage

Use ReentrantMutex instead for MessagePortInternal

Accept origin as a parameter in dispatch_jsval

Fix BorrowMut crash with pending_port_message

Detach port on closure and check for detached during transfer

Enable webmessaging tests

fix webidl

fix
2019-10-19 14:12:22 +08:00
Josh Matthews
421001ae1a Work around crash on Windows when returning JS::Value by value. 2019-08-30 17:29:10 -07:00
bors-servo
90fb4c3589
Auto merge of #23930 - CYBAI:incumbent-global-assertion, r=jdm
Assert incumbent global is always some in get_incumbent_global hook

While working on module script, I'd like to use Promise with a custom
callback with type `Box<dyn TaskBox>` which means we didn't use web API
callbacks as native handlers. However, we'll get a panic from
`enqueue_promise_job` and the panic says we have a `null` incumbent
global. The main problem here is, the Promise API is strongly tied to JS
engine and it always assumes there's a meaningful answer for "what
specific global is this promise associated with". So, when I don't use
the Promise for a specific web API, our engine cannot find a proper
incumbent global for us so that we get the `null` incumbent global
panic.

To make us catch this case easier in the future, we should add the
assertion inside `get_incumbent_global` hook so that we can know this
quickly next time.

Ref: https://mozilla.logbot.info/servo/20190807#c16525481

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because it should just add assertion inside the hook

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23930)
<!-- Reviewable:end -->
2019-08-09 02:54:33 -04:00
marmeladema
6d444afd9e Use safe JSContext in MicrotaskQueue 2019-08-09 00:02:10 +01:00
marmeladema
51e22fbc26 Remove some usage of unsafe code in Promise 2019-08-09 00:02:07 +01:00
CYBAI
28e64fc701 Assert incumbent global is always some in get_incumbent_global hook
While working on module script, I'd like to use Promise with a custom
callback with type `Box<dyn TaskBox>` which means we didn't use web API
callbacks as native handlers. However, we'll get a panic from
`enqueue_promise_job` and the panic says we have a `null` incumbent
global. The main problem here is, the Promise API is strongly tied to JS
engine and it always assumes there's a meaningful answer for "what
specific global is this promise associated with". So, when I don't use
the Promise for a specific web API, our engine cannot find a proper
incumbent global for us so that we get the `null` incumbent global
panic.

To make us catch this case easier in the future, we should add the
assertion inside `get_incumbent_global` hook so that we can know this
quickly next time.

Ref: https://mozilla.logbot.info/servo/20190807#c16525481
2019-08-08 12:39:56 +09:00
marmeladema
88cacfb009 Modify *::get_cx methods to return a safe JSContext instead of a raw one 2019-07-24 09:53:10 +01:00
marmeladema
2fb3f1f983 Callbacks now uses safe JSContext instead of raw JSContext 2019-07-24 08:18:22 +01:00