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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/insert-adjacent.html

Issue 1854003004: Import web-platform-tests@5a8700479d98852455bee6117558897867eb278a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 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
OLDNEW
(Empty)
1 <!doctype html>
2 <meta charset="utf-8">
3 <title></title>
4 <script src="../../../../resources/testharness.js"></script>
5 <script src="../../../../resources/testharnessreport.js"></script>
6 <style>
7 #element {
8 display: none;
9 }
10 </style>
11
12 <div id="element"></div>
13 <div id="log"></div>
14
15 <script>
16 var possiblePositions = {
17 'beforebegin': 'previousSibling'
18 , 'afterbegin': 'firstChild'
19 , 'beforeend': 'lastChild'
20 , 'afterend': 'nextSibling'
21 }
22 var texts = {
23 'beforebegin': 'raclette'
24 , 'afterbegin': 'tartiflette'
25 , 'beforeend': 'lasagne'
26 , 'afterend': 'gateau aux pommes'
27 }
28
29 var el = document.querySelector('#element');
30
31 Object.keys(possiblePositions).forEach(function(position) {
32 var div = document.createElement('h3');
33 test(function() {
34 div.id = texts[position];
35 el.insertAdjacentElement(position, div);
36 assert_equals(el[possiblePositions[position]].id, texts[position]);
37 }, 'insertAdjacentElement(' + position + ', ' + div + ' )');
38
39 test(function() {
40 el.insertAdjacentText(position, texts[position]);
41 assert_equals(el[possiblePositions[position]].textContent, texts[position]);
42 }, 'insertAdjacentText(' + position + ', ' + texts[position] + ' )');
43 });
44
45 test(function() {
46 assert_throws(new TypeError(), function() {
47 el.insertAdjacentElement('afterbegin',
48 document.implementation.createDocumentType("html"))
49 })
50 }, 'invalid object argument insertAdjacentElement')
51 test(function() {
52 var el = document.implementation.createHTMLDocument().documentElement;
53 assert_throws("HIERARCHY_REQUEST_ERR", function() {
54 el.insertAdjacentElement('beforebegin', document.createElement('banane'))
55 })
56 }, 'invalid caller object insertAdjacentElement')
57 test(function() {
58 var el = document.implementation.createHTMLDocument().documentElement;
59 assert_throws("HIERARCHY_REQUEST_ERR", function() {
60 el.insertAdjacentText('beforebegin', 'tomate farcie')
61 })
62 }, 'invalid caller object insertAdjacentText')
63 test(function() {
64 var div = document.createElement('h3');
65 assert_throws("SYNTAX_ERR", function() {
66 el.insertAdjacentElement('heeeee', div)
67 })
68 }, "invalid syntax for insertAdjacentElement")
69 test(function() {
70 assert_throws("SYNTAX_ERR", function() {
71 el.insertAdjacentText('hoooo', 'magret de canard')
72 })
73 }, "invalid syntax for insertAdjacentText")
74 test(function() {
75 var div = document.createElement('div');
76 assert_equals(div.insertAdjacentElement("beforebegin", el), null);
77 }, 'insertAdjacentText should return null');
78
79 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698