Commit graph

25052 commits

Author SHA1 Message Date
bors-servo
044862cfc6
Auto merge of #28611 - servo:notriddle/non-ts, r=jdm
Add docs that say, somewhere, what `non_ts` means

- [x] These changes do not require tests because it's just updating a doc comment
2021-10-09 14:32:52 -04:00
Michael Howell
c9fa1e9fc1
Add docs that say, somewhere, what non_ts means 2021-10-08 16:35:32 -07:00
12101111
0115eb8dd8
Fix UB in hashglobe 2021-10-09 00:01:04 +08:00
bors-servo
42cbba8a8b
Auto merge of #28581 - yvt:fix-xo-attr-setter, r=KiChjang
The condition for exposing a cross-origin setter should be `CrossOriginWritable`, not `CrossOriginReadable`

Fixes `Location#href` being inaccessible from a cross-origin document.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

---
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___
2021-08-19 21:10:10 -04:00
yvt
c25355704d fix(script): the condition for exposing a cross-origin setter is CrossOriginWritable, not CrossOriginReadable
The expression `crossOriginIframe.contentWindow.location.href = "new
href"` takes the following steps: (1) Get the setter for `href` by
invoking `[[GetOwnProperty]]` on `crossOriginIframe.contentWindow.
location`. (2) Call the setter, passing `crossOriginIframe.
contentWindow` and `"new href"`. Since the target `Location` is cross
origin, getting the setter succeeds only if the `CrossOriginWritable`
extended attribute is present on the `href` attribute, and it's present.
However, instead of `CrossOriginWritable`, `CrossOriginReadable` was
checked mistakenly.

Since `Location#href` has `CrossOriginWritable` but not
`CrossOriginReadable`, this bug rendered `Location#href` inaccessible
from a cross-origin document.
2021-08-17 09:26:27 +09:00
Bryce Wilson
f305c82494
Fix compiler warnings 2021-08-14 21:35:15 -07:00
bjorn3
7bc6742a45
Remove unnecessary feature gate 2021-08-13 13:03:46 +02:00
bjorn3
5b0d7fbe5d
Fix lint 2021-08-10 15:34:50 +02:00
bjorn3
92a23f7583
Update script_plugin for rust-lang/rust#85296 2021-08-09 12:01:42 +02:00
yvt
38adb092ad fix(script): "process the iframe attributes" shouldn't invoke the iframe load event steps anymore
This likely originates from a bug that existed in the specification[1].
A `src`-less iframe would fire two `load` events when implemented
according to an affected version of the specification.

[1]: f2839722e1
2021-08-07 11:41:00 +09:00
yvt
3090505fd4 refactor(script): navigate_or_reload_child_browsing_context should only handle cases involving navigation
The initial document creation does not involve navigation, and it would
cause a confusion if this was done by a function which has `navigation`
in its name. This commit renames `navigate_or_reload_child_browsing_
context` to `start_new_pipeline`, and introduces a new function which
has the original name and is dedicated to handle navigation.
2021-08-03 09:11:19 +09:00
bors-servo
bd92fad81a
Auto merge of #28546 - yvt:feat-cow-infra, r=jdm
Implement `Location`'s custom internal methods

This PR partly resurrects #16501 and introduces the use of principals object to associate objects and Realms with origins. Using this infrastructure, this PR implements [the custom internal methods][1] of the `Location` interface, which is "maybe-cross-origin".

Unimplemented/incomplete things:

 - Other maybe-cross-origin interfaces, namely `WindowProxy` and `DissimilarWindowLocation`, aren't implemented correctly yet (causing most test cases of `tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html` to fail).
     - `WindowProxy`: #28556
 - [The "perform a security check" operation][2] and `Location`'s non-cross-origin properties' relevant `Document` origin checks aren't implemented either (not sure if they are covered by the existing tests).
 - There are a slight deviation from the standard and inefficiency in `CrossOriginGetOwnPropertyHelper`'s current implementation.
     - #28557

[1]: https://html.spec.whatwg.org/multipage/#the-location-interface
[2]: https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #16243 and make some progress in #2382

---
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___
2021-08-01 10:31:40 -04:00
yvt
afbe2fa1f2 fix(script): don't pass an unrooted slice to from_rooted_slice 2021-07-28 09:10:55 +09:00
yvt
110b3ab6bc style(script): add underscore to unused parameter 2021-07-27 22:38:32 +09:00
yvt
b6ee398b91 refactor(script): make grouping clearer while keeping test-tidy happy 2021-07-27 22:26:28 +09:00
yvt
2e0dd0816f refactor(script): refactor common code into PropertyDefiner.generateUnguardedArray
There are code fragments in `(Method|Attr)Definer.generateArray` that
are much alike. This commit refactors them into a new method of
`PropertyDefiner` named `generateUnguardedArray` (in contrast to the
existing method `generateGuardedArray`).
2021-07-27 01:31:08 +09:00
yvt
c28e98ec40 refactor(script): squash CGDOMJSProxyHandler_set
The implementation in `crate::dom::bindings::proxyhandler::
maybe_cross_origin_set_rawcx` is now directly assigned to `ProxyTraps::
set`.
2021-07-26 01:07:29 +09:00
yvt
66a4ea0727 doc(script): fix comments
`History` is not a maybe-cross-origin object. I must have been very
sleepy when I wrote this.
2021-07-26 01:06:24 +09:00
yvt
e98cba1896 refactor(script): don't conjure up ServoJSPrincipals in ServoJSPrincipalsRef::deref
It's technically safe to do because of `#[repr(transparent)]` and is a
prerequisite of having `ServoJSPrincipalsRef: Copy`, but I guess it's
not worth an `unsafe` block.
2021-07-25 19:36:06 +09:00
yvt
690d8462a5 refactor(script): apply suggestions 2021-07-25 18:45:22 +09:00
yvt
df5e2911fd
refactor(script): apply suggestion
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2021-07-25 17:20:09 +09:00
yvt
41b3726271 feat: shorten thread names
The Linux kernel imposes a 15-byte limit on thread names[1]. This means
information that does not fit in this limit, e.g., the pipeline ID of
layout and script threads, is lost in a debugger and profiler (see the
first column of the table below).

This commit shortens the thread names used in Servo to maximize the
amount of information conveyed. It also rectifies some inconsistencies
in the names.

|       Before      |       After       |
|-------------------|-------------------|
| `BluetoothThread` | `Bluetooth`       |
| `CanvasThread`    | `Canvas`          |
| `display alert d` | `AlertDialog`     |
| `FontCacheThread` | `FontCache`       |
| `GLPlayerThread`  | `GLPlayer`        |
| `HTML Parser`     | `Parse:www.examp` |
| `LayoutThread Pi` | `Layout(1,1)`     |
| `Memory profiler` | `MemoryProfiler`  |
| `Memory profiler` | `MemoryProfTimer` |
| `OfflineAudioCon` | `OfflineACResolv` |
| `PullTimelineMar` | `PullTimelineDat` |
| `ScriptThread Pi` | `Script(1,1)`     |
| `WebWorker for h` | `WW:www.example.` |
| `ServiceWorker f` | `SW:www.example.` |
| `ServiceWorkerMa` | `SvcWorkerManage` |
| `Time profiler t` | `TimeProfTimer`   |
| `Time profiler`   | `TimeProfiler`    |
| `WebGL thread`    | `WebGL`           |
| `Choose a device` | `DevicePicker`    |
| `Pick a file`     | `FilePicker`      |
| `Pick files`      | `FilePicker`      |

[1]: https://stackoverflow.com/questions/5026531/thread-name-longer-than-15-chars
2021-07-19 00:57:48 +09:00
Josh Matthews
8d5dd66ed3 Update to 7/17 nightly. 2021-07-17 16:41:38 -04:00
yvt
d733abfca0 style(script): address test-tidy errors 2021-07-17 17:06:05 +09:00
yvt
a6b2f75656 feat(script): implement getOwnEnumerablePropertyKeys for Location
Fixes the following assertion from `tests/wpt/web-platform-tests/html/
browsers/origin/cross-origin-objects/cross-origin-objects.html`:

    assert_equals(Object.keys(win.location).length, 0,
                        "Object.keys() gives the right answer for cross-origin Location");
2021-07-17 15:26:15 +09:00
yvt
75242d6c4c feat(script): implement the last step of CrossOriginOwnPropertyKeys 2021-07-17 15:26:15 +09:00
yvt
1bcbdae27b doc(script): improve comments in proxyhandler.rs 2021-07-17 15:26:15 +09:00
yvt
4bc3453174 feat(script): Implement [[Set]] for Location 2021-07-17 15:26:15 +09:00
yvt
bdd20f0139 feat(script): enable js::ProxyOptions::setLazyProto for maybe-cross-origin objects
Setting the lazy proto option allows proxy handlers to provide dynamic
prototype objects. This is necessary for the customization of
`ProxyTraps::{get,set}PrototypeOf` to actually take effect.
2021-07-17 15:26:15 +09:00
yvt
722a239715 feat(script): Implement [[{Get,Set}PrototypeOf]] for Location 2021-07-17 15:26:15 +09:00
Leonardo Razovic
ef7eb02b8d
Upgrade to uluru 2 2021-07-15 18:28:12 +02:00
yvt
41cce140bc feat(script): implement some of the non-ordinary internal methods of Location
<https://html.spec.whatwg.org/multipage/#the-location-interface>

 - `[[GetPrototypeOf]]`: not yet
 - `[[SetPrototypeOf]]`: not yet
 - `[[IsExtensible]]`: `proxyhandler::is_extensible`
 - `[[PreventExtensions]]`: `proxyhandler::prevent_extensions`
 - `[[GetOwnProperty]]`: `CGDOMJSProxyHandler_getOwnPropertyDescriptor` (updated)
 - `[[DefineOwnProperty]]`: `CGDOMJSProxyHandler_defineProperty` (updated)
 - `[[Get]]`: `CGDOMJSProxyHandler_get` (updated)
 - `[[Set]]`: not yet
 - `[[Delete]]`: `CGDOMJSProxyHandler_delete` (updated)
 - `[[OwnPropertyKeys]]`: `CGDOMJSProxyHandler_ownPropertyKeys` (updated)
2021-07-16 01:26:05 +09:00
yvt
1d970b1351 feat(script): add CrossOrigin*able attributes to Window and Location's members 2021-07-15 00:07:04 +09:00
yvt
863c90acd8 Merge remote-tracking branch 'upstream/master' into feat-cow-infra 2021-07-14 01:00:04 +09:00
yvt
f884506dfb refactor(script): auto ref-count ServoJSPrincipals 2021-07-13 23:08:23 +09:00
yvt
b77ee8721b refactor(script): rename ServoJSPrincipal to ServoJSPrincipals 2021-07-13 21:51:54 +09:00
yvt
320965bfb9 refactor(script): move crate::dom::bindings::{utils → principals)::ServoJSPrincipal 2021-07-13 21:45:21 +09:00
yvt
dfb4a0c844 refactor(script): remove {DedicatedWorkerGlobalScope, ServiceWorkerGlobalScope}::origin 2021-07-13 21:27:26 +09:00
yvt
90b78a193c Revert "feat(script): add {DissimilarOriginWindow, PaintWorkletGlobalScope, TestWorkletGlobalScope}::origin"
This reverts commit 5959c2ef9b.
2021-07-13 21:12:44 +09:00
yvt
c3de9b72a6 feat(script): use GlobalScope::origin when creating a principals object
The concrete types of `[Global]` DOM interfaces have `origin` methods,
which were used before this commit. Some of them just delegate to
`GlobalScope::origin` while others are implemented differently. This
commit changes the created principals objects' associated origins in the
following way:

 - `DedicatedWorkerGlobalScope` - was `WorkerGlobalScope::worker_url`
 - `DissimilarOriginWindow` - no change
 - `PaintWorkletGlobalScope` - no change
 - `ServiceWorkerGlobalScope` - was `ServiceWorkerGlobalScope::scope_url`
 - `TestWorkletGlobalScope` - no change
 - `Window` - no change
2021-07-13 21:06:52 +09:00
yvt
52c60e0bf5
doc(script): use the recommended format of a WHATWG link
Enforced by `./mach test-tidy`
2021-07-13 12:19:49 +09:00
yvt
65aa3b0b4d doc(script): update comments in run_worker_scope and run_serviceworker_scope
The step numbers changed over time.

Note that service workers and non-service workers use different steps
defined in different specifications.
2021-07-13 09:31:17 +09:00
yvt
e9af95ec0f fix(script): Set DedicatedWorkerGlobalScope's origin correctly
<https://html.spec.whatwg.org/multipage/workers.html#worker-processing-model>

> 10.2.4 Processing model
>
> When a user agent is to run a worker for a script with `Worker` or
> `SharedWorker` object `worker`, [...] it must run the following steps.
>
> [...]
>
> 8. Set up a worker environment settings object with `realm execution
>    context` and `outside settings`, and let `inside settings` be the
>    result.

<https://html.spec.whatwg.org/multipage/workers.html#script-settings-for-workers>

> To **set up a worker environment settings object**, given a JavaScript
> execution context `execution context` and environment settings object
> `outside settings`:
>
> 1. Let `inherited origin` be `outside settings`'s origin.
>
> 2. Let `realm` be the value of `execution context`'s Realm component.
>
> 3. Let `worker global scope` be `realm`'s global object.
>
> 4. Let `settings object` be a new environment settings object whose
>    algorithms are defined as follows:
>
>    **The origin** Return a unique opaque origin if `worker global
>    scope`'s url's scheme is "data", and `inherited origin` otherwise.
2021-07-13 09:31:15 +09:00
yvt
3550270cd0 fix(script): implement the destroy-principals callback correctly 2021-07-12 01:30:02 +09:00
yvt
e786627199 fix(script): apply some of the changes requested in the review comments of #16501 2021-07-12 01:29:41 +09:00
yvt
2f3a14b491 doc(script): prettify a comment 2021-07-12 01:07:30 +09:00
yvt
bbb2cc42fe fix(script): remove debug printing 2021-07-12 00:02:28 +09:00
yvt
5959c2ef9b feat(script): add {DissimilarOriginWindow, PaintWorkletGlobalScope, TestWorkletGlobalScope}::origin 2021-07-11 23:30:42 +09:00
yvt
bfa2026220 feat(script): remove the call to JS_SetWrapObjectCallbacks
We don't make CCWs anymore.
2021-07-11 23:30:40 +09:00
yvt
40fbe6b722 chore(deps): update mozjs
- 798c5b6: Bring `RustJSPrincipals` back
2021-07-11 23:01:21 +09:00