servo/components/script
bors-servo f6463c89d5
Auto merge of #20051 - jonleighton:prevent-invalid-selections, r=jdm
Disallow mutating the internals of TextInput

The TextInput::assert_ok_selection() method is meant to ensure that we
are not getting into a state where a selection refers to a location in
the control's contents which doesn't exist.

However, before this change we could have a situation where the
internals of the TextInput are changed by another part of the code,
without using its public API. This could lead to us having an invalid
selection.

I did manage to trigger such a situation (see the test added in this
commit) although it is quite contrived. There may be others that I
didn't think of, and it's also possible that future changes could
introduce new cases. (Including ones which trigger panics, if indexing
is used on the assumption that the selection indices are always valid.)

The current HTML specification doesn't explicitly say that
selectionStart/End must remain within the length of the content, but
that does seems to be the consensus reached in a discussion of this:

https://github.com/whatwg/html/issues/2424

The test case I've added here is currently undefined in the spec which
is why I've added it in tests/wpt/mozilla.

<!-- 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/20051)
<!-- Reviewable:end -->
2018-02-22 11:47:40 -05:00
..
docs Rename Root<T> to DomRoot<T> 2017-09-26 09:49:10 +02:00
dom Auto merge of #20051 - jonleighton:prevent-invalid-selections, r=jdm 2018-02-22 11:47:40 -05:00
task_source added pipelines to all task sources 2017-10-25 14:25:58 +01:00
body.rs Replace all uses of the heapsize crate with malloc_size_of. 2017-10-18 22:20:37 +11:00
build.rs Use env::var_os to read paths from the environment 2017-10-20 09:03:21 -07:00
Cargo.toml remove mozbrowser code 2018-02-13 09:40:06 +01:00
clipboard_provider.rs make use of ScriptToConstellationChan 2017-08-15 08:22:09 +02:00
CMakeLists.txt
devtools.rs Add layout RPC query for getting an element's style 2018-01-28 10:59:45 +01:00
document_loader.rs Add a topLevelDomComplete metric. 2017-12-14 16:48:19 -06:00
fetch.rs Add FetchCanceller RAII handle 2017-11-21 16:45:03 -08:00
layout_image.rs Merge request type and destination 2017-10-23 11:19:35 -07:00
lib.rs remove mozbrowser code 2018-02-13 09:40:06 +01:00
mem.rs Replace all uses of the heapsize crate with malloc_size_of. 2017-10-18 22:20:37 +11:00
microtask.rs Replace all uses of the heapsize crate with malloc_size_of. 2017-10-18 22:20:37 +11:00
network_listener.rs Introduce TaskOnce 2017-09-20 10:37:09 +02:00
script_runtime.rs Remove js.mem.gc.refresh_frame_slices.enabled pref 2018-01-06 23:11:48 +01:00
script_thread.rs remove mozbrowser code 2018-02-13 09:40:06 +01:00
serviceworker_manager.rs remove extra spaces after keywords 2017-07-20 00:45:02 +03:00
serviceworkerjob.rs added pipelines to all task sources 2017-10-25 14:25:58 +01:00
stylesheet_loader.rs Use encoding-rs instead of rust-encoding for CSS parsing 2017-10-31 19:08:43 +01:00
task.rs Make usage of core_intrinsics optional 2017-10-16 20:20:21 +02:00
test.rs Parse srcset attribute 2017-10-03 13:18:01 +02:00
textinput.rs Disallow mutating the internals of TextInput 2018-02-16 11:24:12 +01:00
timers.rs Replace all uses of the heapsize crate with malloc_size_of. 2017-10-18 22:20:37 +11:00
unpremultiplytable.rs
webdriver_handlers.rs Rename Root<T> to DomRoot<T> 2017-09-26 09:49:10 +02:00