Commit 89ebb687 authored by Bhagirathi Satpathy's avatar Bhagirathi Satpathy Committed by Commit Bot

Support MediaList |toString| method

Added stringifier to support MediaList |toString| method.
Specification:
https://drafts.csswg.org/cssom/#the-medialist-interface

Bug:

Change-Id: I0dd14cd1843a5d3fde424021a443669db374df85
Reviewed-on: https://chromium-review.googlesource.com/890959Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Bhagirathi Satpathy <bhagirathi.s@samsung.com>
Cr-Commit-Position: refs/heads/master@{#532388}
parent 26e51bf8
......@@ -14,6 +14,7 @@
var media = document.styleSheets[0].cssRules[0].media;
assert_equals(media.length, 3, "MediaList length attribute");
assert_equals(media.mediaText, "screen and (min-width: 480px), print, projection", "MediaList mediaText attribute");
assert_equals(media.toString(), "screen and (min-width: 480px), print, projection", "MediaList toString method");
assert_equals(media[0], "screen and (min-width: 480px)", "MediaList indexed getter");
assert_equals(media[1], "print", "MediaList indexed getter");
assert_equals(media[2], "projection", "MediaList indexed getter");
......@@ -24,6 +25,7 @@
media.deleteMedium("print");
assert_equals(media.length, 2, "MediaList length attribute after delete method");
assert_equals(media.mediaText, "screen and (min-width: 480px), projection", "MediaList mediaText attribute after delete method");
assert_equals(media.toString(), "screen and (min-width: 480px), projection", "MediaList toString method after delete method");
assert_equals(media[1], "projection", "MediaList indexed getter after delete method");
assert_equals(media[2], undefined, "MediaList indexed getter with out of range after delete method");
assert_equals(media.item(1), "projection", "MediaList indexed getter after delete method");
......@@ -32,6 +34,7 @@
media.appendMedium("speech");
assert_equals(media.length, 3, "MediaList length attribute after append method");
assert_equals(media.mediaText, "screen and (min-width: 480px), projection, speech", "MediaList mediaText attribute after append method");
assert_equals(media.toString(), "screen and (min-width: 480px), projection, speech", "MediaList toString method after append method");
assert_equals(media[1], "projection", "MediaList indexed getter after append method");
assert_equals(media[2], "speech", "MediaList indexed getter after append method");
assert_equals(media[3], undefined, "MediaList indexed getter with out of range after append method");
......
This is a testharness.js-based test.
Found 399 tests; 313 PASS, 86 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 399 tests; 314 PASS, 85 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS Test driver
PASS HTMLElement interface: attribute style
PASS HTMLElement interface: style_element must inherit property "style" with the proper type
......@@ -27,7 +27,7 @@ PASS MediaList interface object name
FAIL MediaList interface: existence and properties of interface prototype object assert_equals: prototype of MediaList.prototype is not Array.prototype expected [] but got object "[object Object]"
PASS MediaList interface: existence and properties of interface prototype object's "constructor" property
PASS MediaList interface: attribute mediaText
FAIL MediaList interface: stringifier assert_own_property: interface prototype object missing non-static operation expected property "toString" missing
PASS MediaList interface: stringifier
PASS MediaList interface: attribute length
PASS MediaList interface: operation item(unsigned long)
PASS MediaList interface: operation appendMedium(CSSOMString)
......
......@@ -74,7 +74,7 @@ PASS resultArray[2].i is '2'
PASS resultArray[2].item is cssStyleDeclaration.item(2)
[object MediaList]
PASS resultArray.length is 8
PASS resultArray.length is 9
PASS resultArray[0].i is '0'
PASS resultArray[0].item is mediaList.item(0)
PASS resultArray[1].i is '1'
......
......@@ -191,7 +191,7 @@ shouldBe("resultArray[2].item", "cssStyleDeclaration.item(2)");
// MediaList
var mediaList = document.styleSheets[3].cssRules[0].media;
resultArray = iterateList(mediaList);
shouldBe("resultArray.length", "8");
shouldBe("resultArray.length", "9");
shouldBe("resultArray[0].i", "'0'");
shouldBe("resultArray[0].item", "mediaList.item(0)");
shouldBe("resultArray[1].i", "'1'");
......
......@@ -3478,6 +3478,7 @@ interface MediaList
method constructor
method deleteMedium
method item
method toString
setter mediaText
interface MediaQueryList : EventTarget
attribute @@toStringTag
......
......@@ -4156,6 +4156,7 @@ interface MediaList
method constructor
method deleteMedium
method item
method toString
setter mediaText
interface MediaMetadata
attribute @@toStringTag
......
......@@ -29,8 +29,7 @@
[
Exposed=Window
] interface MediaList {
// TODO(foolip): [TreatNullAs=EmptyString] stringifier attribute DOMString mediaText;
attribute DOMString? mediaText;
[TreatNullAs=EmptyString] stringifier attribute DOMString mediaText;
readonly attribute unsigned long length;
[Measure] getter DOMString? item(unsigned long index);
// TODO(foolip): appendMedium() and deleteMedium() should never throw.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment