Auto merge of #24220 - rasviitanen:domstringlist, r=jdm

add webidl bindings for DOMStringList

<!-- Please describe your changes on the following line: -->
To prepare for the implementation of `IndexedDB` a DOM interface for `DOMStringList` is added.

This change:
* Adds a new IDL file for `DOMStringList`
* Lists `domstringlist.rs` in `mod.rs`
* Defines a new DOMStruct `DOMStringList`
* Changes some test expectations related to `DOMStringList`
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #24208

- [X] These changes do not require tests because:
We are not yet able to fully test the functions of `DOMStringList` in the WPT, because it is not possible to create an object of the type `DOMStringList` until e.g. `indexeddb` or `location.ancestorOrigins` is implemented.

<!-- 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/24220)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-09-17 23:53:08 -04:00 committed by GitHub
commit 745857066c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 84 additions and 216 deletions

View file

@ -0,0 +1,59 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::DOMStringListBinding;
use crate::dom::bindings::codegen::Bindings::DOMStringListBinding::DOMStringListMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::window::Window;
use dom_struct::dom_struct;
#[dom_struct]
pub struct DOMStringList {
reflector_: Reflector,
strings: Vec<DOMString>,
}
impl DOMStringList {
#[allow(unused)]
pub fn new_inherited(strings: Vec<DOMString>) -> DOMStringList {
DOMStringList {
reflector_: Reflector::new(),
strings,
}
}
#[allow(unused)]
pub fn new(window: &Window, strings: Vec<DOMString>) -> DomRoot<DOMStringList> {
reflect_dom_object(
Box::new(DOMStringList::new_inherited(strings)),
window,
DOMStringListBinding::Wrap,
)
}
}
// https://html.spec.whatwg.org/multipage/#domstringlist
impl DOMStringListMethods for DOMStringList {
// https://html.spec.whatwg.org/multipage/#dom-domstringlist-length
fn Length(&self) -> u32 {
self.strings.len() as u32
}
// https://html.spec.whatwg.org/multipage/#dom-domstringlist-item
fn Item(&self, index: u32) -> Option<DOMString> {
self.strings.get(index as usize).cloned()
}
// https://html.spec.whatwg.org/multipage/#dom-domstringlist-contains
fn Contains(&self, string: DOMString) -> bool {
self.strings.contains(&string)
}
// check-tidy: no specs after this line
fn IndexedGetter(&self, index: u32) -> Option<DOMString> {
self.Item(index)
}
}

View file

@ -293,6 +293,7 @@ pub mod dompointreadonly;
pub mod domquad;
pub mod domrect;
pub mod domrectreadonly;
pub mod domstringlist;
pub mod domstringmap;
pub mod domtokenlist;
pub mod element;

View file

@ -0,0 +1,18 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is
* https://html.spec.whatwg.org/multipage/#domstringlist
*
* Copyright:
* To the extent possible under law, the editors have waived all copyright and
* related or neighboring rights to this work.
*/
[Exposed=(Window,Worker)]
interface DOMStringList {
readonly attribute unsigned long length;
getter DOMString? item(unsigned long index);
boolean contains(DOMString string);
};

View file

@ -167,9 +167,6 @@
[MessagePort interface object length]
expected: FAIL
[DOMStringList interface object length]
expected: FAIL
[Navigator interface: window.navigator must inherit property "onLine" with the proper type]
expected: FAIL
@ -179,9 +176,6 @@
[ApplicationCache interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[DOMStringList interface: operation item(unsigned long)]
expected: FAIL
[Navigator interface: attribute hardwareConcurrency]
expected: FAIL
@ -446,9 +440,6 @@
[OffscreenCanvas interface: existence and properties of interface prototype object]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[DataTransferItemList interface object length]
expected: FAIL
@ -764,9 +755,6 @@
[CanvasRenderingContext2D interface: calling drawFocusIfNeeded(Path2D, Element) on document.createElement("canvas").getContext("2d") with too few arguments must throw TypeError]
expected: FAIL
[DOMStringList interface: existence and properties of interface object]
expected: FAIL
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "scrollPathIntoView(Path2D)" with the proper type]
expected: FAIL
@ -986,9 +974,6 @@
[ElementInternals interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[ElementInternals interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
@ -1181,9 +1166,6 @@
[OffscreenCanvasRenderingContext2D interface: operation getImageData(long, long, long, long)]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object]
expected: FAIL
[SVGSVGElement interface: attribute onpopstate]
expected: FAIL
@ -1202,9 +1184,6 @@
[BroadcastChannel interface: operation close()]
expected: FAIL
[DOMStringList interface: attribute length]
expected: FAIL
[SVGElement interface: attribute onresize]
expected: FAIL
@ -1232,9 +1211,6 @@
[TextMetrics interface: attribute fontBoundingBoxDescent]
expected: FAIL
[DOMStringList interface object name]
expected: FAIL
[ApplicationCache must be primary interface of window.applicationCache]
expected: FAIL
@ -1520,9 +1496,6 @@
[TextMetrics interface object name]
expected: FAIL
[DOMStringList interface: operation contains(DOMString)]
expected: FAIL
[External interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL

View file

@ -74,12 +74,6 @@
[MessagePort interface object length]
expected: FAIL
[DOMStringList interface object length]
expected: FAIL
[DOMStringList interface: operation item(unsigned long)]
expected: FAIL
[OffscreenCanvasRenderingContext2D interface: operation strokeText(DOMString, unrestricted double, unrestricted double, unrestricted double)]
expected: FAIL
@ -194,9 +188,6 @@
[OffscreenCanvasRenderingContext2D interface: operation stroke(Path2D)]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[ImageBitmap interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
@ -350,9 +341,6 @@
[OffscreenCanvasRenderingContext2D interface: operation setTransform(unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double)]
expected: FAIL
[DOMStringList interface: existence and properties of interface object]
expected: FAIL
[OffscreenCanvasRenderingContext2D interface object name]
expected: FAIL
@ -440,15 +428,9 @@
[OffscreenCanvasRenderingContext2D interface: operation putImageData(ImageData, long, long, long, long, long, long)]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[WorkerNavigator interface: member taintEnabled]
expected: FAIL
[DOMStringList interface: operation contains(DOMString)]
expected: FAIL
[DedicatedWorkerGlobalScope interface: calling cancelAnimationFrame(unsigned long) on self with too few arguments must throw TypeError]
expected: FAIL
@ -524,9 +506,6 @@
[BroadcastChannel interface: attribute onmessage]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object]
expected: FAIL
[Path2D interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
@ -542,9 +521,6 @@
[WorkerGlobalScope interface: self must inherit property "onunhandledrejection" with the proper type]
expected: FAIL
[DOMStringList interface: attribute length]
expected: FAIL
[Path2D interface: operation ellipse(unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double, boolean)]
expected: FAIL
@ -557,9 +533,6 @@
[WorkerGlobalScope interface: attribute ononline]
expected: FAIL
[DOMStringList interface object name]
expected: FAIL
[OffscreenCanvasRenderingContext2D interface: attribute textBaseline]
expected: FAIL

View file

@ -299,33 +299,6 @@
[HTMLAllCollection interface: calling item(DOMString) on document.all with too few arguments must throw TypeError]
expected: FAIL
[DOMStringList interface: existence and properties of interface object]
expected: FAIL
[DOMStringList interface object length]
expected: FAIL
[DOMStringList interface object name]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[DOMStringList interface: attribute length]
expected: FAIL
[DOMStringList interface: operation item(unsigned long)]
expected: FAIL
[DOMStringList interface: operation contains(DOMString)]
expected: FAIL
[HTMLElement interface: attribute translate]
expected: FAIL
@ -9161,33 +9134,6 @@
[HTML IDL tests]
expected: FAIL
[DOMStringList interface: existence and properties of interface object]
expected: FAIL
[DOMStringList interface object length]
expected: FAIL
[DOMStringList interface object name]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[DOMStringList interface: attribute length]
expected: FAIL
[DOMStringList interface: operation item(unsigned long)]
expected: FAIL
[DOMStringList interface: operation contains(DOMString)]
expected: FAIL
[TextTrack interface: attribute inBandMetadataTrackDispatchType]
expected: FAIL
@ -10709,24 +10655,5 @@
[SVGElement interface: attribute onformdata]
expected: FAIL
[DOMStringList interface: calling item(unsigned long) on location.ancestorOrigins with too few arguments must throw TypeError]
expected: FAIL
[DOMStringList interface: calling contains(DOMString) on location.ancestorOrigins with too few arguments must throw TypeError]
expected: FAIL
[DOMStringList interface: location.ancestorOrigins must inherit property "contains(DOMString)" with the proper type]
expected: FAIL
[Stringification of location.ancestorOrigins]
expected: FAIL
[DOMStringList interface: location.ancestorOrigins must inherit property "item(unsigned long)" with the proper type]
expected: FAIL
[DOMStringList must be primary interface of location.ancestorOrigins]
expected: FAIL
[DOMStringList interface: location.ancestorOrigins must inherit property "length" with the proper type]
expected: FAIL

View file

@ -312,12 +312,6 @@
[MessagePort interface: attribute onmessageerror]
expected: FAIL
[DOMStringList interface object length]
expected: FAIL
[DOMStringList interface: operation item(unsigned long)]
expected: FAIL
[OffscreenCanvasRenderingContext2D interface: operation restore()]
expected: FAIL
@ -381,9 +375,6 @@
[OffscreenCanvasRenderingContext2D interface: operation stroke(Path2D)]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[ImageBitmap interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
@ -480,9 +471,6 @@
[OffscreenCanvasRenderingContext2D interface: operation setTransform(unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double)]
expected: FAIL
[DOMStringList interface: existence and properties of interface object]
expected: FAIL
[OffscreenCanvasRenderingContext2D interface object name]
expected: FAIL
@ -537,15 +525,9 @@
[OffscreenCanvasRenderingContext2D interface: operation putImageData(ImageData, long, long, long, long, long, long)]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[WorkerNavigator interface: member taintEnabled]
expected: FAIL
[DOMStringList interface: operation contains(DOMString)]
expected: FAIL
[OffscreenCanvasRenderingContext2D interface: operation moveTo(unrestricted double, unrestricted double)]
expected: FAIL
@ -579,9 +561,6 @@
[OffscreenCanvasRenderingContext2D interface: operation fill(Path2D, CanvasFillRule)]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object]
expected: FAIL
[OffscreenCanvasRenderingContext2D interface: operation createRadialGradient(double, double, double, double, double, double)]
expected: FAIL
@ -591,18 +570,12 @@
[WorkerGlobalScope interface: self must inherit property "onunhandledrejection" with the proper type]
expected: FAIL
[DOMStringList interface: attribute length]
expected: FAIL
[Path2D interface: operation ellipse(unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double, boolean)]
expected: FAIL
[MessageEvent interface: new MessageEvent("message", { data: 5 }) must inherit property "ports" with the proper type]
expected: FAIL
[DOMStringList interface object name]
expected: FAIL
[OffscreenCanvasRenderingContext2D interface: operation isPointInStroke(Path2D, unrestricted double, unrestricted double)]
expected: FAIL

View file

@ -1,28 +1,5 @@
[domstringlist-interface.html]
type: testharness
[DOMStringList interface: existence and properties of interface object]
expected: FAIL
[DOMStringList interface object length]
expected: FAIL
[DOMStringList interface object name]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[DOMStringList interface: attribute length]
expected: FAIL
[DOMStringList interface: operation item(unsigned long)]
expected: FAIL
[DOMStringList interface: operation contains(DOMString)]
expected: FAIL
[DOMStringList must be primary interface of location.ancestorOrigins]
expected: FAIL
@ -53,7 +30,3 @@
[DOMStringList interface: location.ancestorOrigins must inherit property "contains(DOMString)" with the proper type]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL

View file

@ -1,31 +0,0 @@
[domstringlist-interface.worker.html]
type: testharness
[DOMStringList interface: existence and properties of interface object]
expected: FAIL
[DOMStringList interface object length]
expected: FAIL
[DOMStringList interface object name]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[DOMStringList interface: attribute length]
expected: FAIL
[DOMStringList interface: operation item(unsigned long)]
expected: FAIL
[DOMStringList interface: operation contains(DOMString)]
expected: FAIL
[DOMStringList interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[Untitled]
expected: FAIL

View file

@ -18959,7 +18959,7 @@
"testharness"
],
"mozilla/interfaces.html": [
"f30dd3de4087a45476745c4a41dd6a5f7e9365e3",
"7aed97b42d8fe974ea489db66905d9fbc0edb84d",
"testharness"
],
"mozilla/interfaces.js": [
@ -18967,7 +18967,7 @@
"support"
],
"mozilla/interfaces.worker.js": [
"d14b58eb87568f05c398ae6953d4a0c17943219b",
"802fe64ebfc86480f3c5adc80718f550d09d330b",
"testharness"
],
"mozilla/invalid-this.html": [

View file

@ -69,8 +69,9 @@ test_interfaces([
"DOMException",
"DOMImplementation",
"DOMParser",
"DOMTokenList",
"DOMStringList",
"DOMStringMap",
"DOMTokenList",
"Element",
"ErrorEvent",
"Event",

View file

@ -18,6 +18,7 @@ test_interfaces([
"DOMQuad",
"DOMRect",
"DOMRectReadOnly",
"DOMStringList",
"CustomEvent",
"DedicatedWorkerGlobalScope",
"DOMException",