Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: LayoutTests/imported/web-platform-tests/html/semantics/forms/the-select-element/select-remove.html

Issue 1144143009: W3C Test: Import web-platform-tests/html/semantics (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!doctype html>
2 <meta charset=utf-8>
3 <title>HTMLSelectElement.remove</title>
4 <link rel="author" title="Ms2ger" href="Ms2ger@gmail.com">
5 <link rel="help" href="https://dom.spec.whatwg.org/#dom-childnode-remove">
6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-select-remove ">
7 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-htmloptionsco llection-remove">
8 <script src="../../../../../../resources/testharness.js"></script>
9 <script src="../../../../../../resources/testharnessreport.js"></script>
10 <div id=log></div>
11 <script>
12 function testRemove(getter, desc) {
13 test(function() {
14 var div = document.createElement("div");
15 var select = document.createElement("select");
16 div.appendChild(select);
17 assert_equals(select.parentNode, div);
18
19 var options = [];
20 for (var i = 0; i < 3; ++i) {
21 var option = document.createElement("option");
22 option.textContent = String(i);
23 select.appendChild(option);
24 options.push(option);
25 }
26
27 getter(select).remove(-1);
28 assert_array_equals(select.options, options, "After remove(-1)");
29 assert_equals(select.parentNode, div);
30
31 getter(select).remove(3);
32 assert_array_equals(select.options, options, "After remove(3)");
33 assert_equals(select.parentNode, div);
34
35 getter(select).remove(0);
36 assert_array_equals(select.options, [options[1], options[2]], "After remove( 0)");
37 assert_equals(select.parentNode, div);
38 }, desc)
39 }
40 testRemove(function(select) { return select; }, "select.remove(n) should work");
41 testRemove(function(select) { return select.options; }, "select.options.remove(n ) should work");
42 test(function() {
43 var div = document.createElement("div");
44 var select = document.createElement("select");
45 div.appendChild(select);
46 assert_equals(select.parentNode, div);
47 assert_equals(div.firstChild, select);
48
49 select.remove();
50 assert_equals(select.parentNode, null);
51 assert_equals(div.firstChild, null);
52 }, "remove() should work on select elements.")
53 test(function() {
54 var div = document.createElement("div");
55 var select = document.createElement("select");
56 div.appendChild(select);
57 assert_equals(select.parentNode, div);
58 assert_equals(div.firstChild, select);
59
60 Element.prototype.remove.call(select);
61 assert_equals(select.parentNode, null);
62 assert_equals(div.firstChild, null);
63 }, "Element#remove() should work on select elements.")
64 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698