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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/domparsing/createContextualFragment.html

Issue 2623223003: Import wpt@82173128ef6f536e5faaafc29eecc521380f81ae (Closed)
Patch Set: Modify TestExpectations or download new baselines for tests. Created 3 years, 11 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
1 <!doctype html> 1 <!doctype html>
2 <title>createContextualFragment() tests</title> 2 <title>createContextualFragment() tests</title>
3 <div id=log></div> 3 <div id=log></div>
4 <script src=/resources/testharness.js></script> 4 <script src=/resources/testharness.js></script>
5 <script src=/resources/testharnessreport.js></script> 5 <script src=/resources/testharnessreport.js></script>
6 <script> 6 <script>
7 // We are not testing XML documents here, because apparently it's not clear 7 // We are not testing XML documents here, because apparently it's not clear
8 // what we want to happen there. We also aren't testing the HTML parser in any 8 // what we want to happen there. We also aren't testing the HTML parser in any
9 // depth, just some basic sanity checks. 9 // depth, just some basic sanity checks.
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 test(function() { 77 test(function() {
78 assert_false(passed, "Sanity check"); 78 assert_false(passed, "Sanity check");
79 var range = document.createRange(); 79 var range = document.createRange();
80 range.selectNodeContents(document.documentElement); 80 range.selectNodeContents(document.documentElement);
81 var fragment = range.createContextualFragment("<script>passed = true</s" + "cript>"); 81 var fragment = range.createContextualFragment("<script>passed = true</s" + "cript>");
82 assert_false(passed, "Fragment created but not yet added to document, sh ould not have run"); 82 assert_false(passed, "Fragment created but not yet added to document, sh ould not have run");
83 document.body.appendChild(fragment); 83 document.body.appendChild(fragment);
84 assert_true(passed, "Fragment created and added to document, should run" ); 84 assert_true(passed, "Fragment created and added to document, should run" );
85 }, "<script>s should be run when appended to the document (but not before)"); 85 }, "<script>s should be run when appended to the document (but not before)");
86 86
87 // Historical bugs in browsers; see https://github.com/whatwg/html/issues/2222
88
89 [
90 // Void
91 "area",
92 "base",
93 "basefont",
94 "bgsound",
95 "br",
96 "col",
97 "embed",
98 "frame",
99 "hr",
100 "img",
101 "input",
102 "keygen",
103 "link",
104 "meta",
105 "param",
106 "source",
107 "track",
108 "wbr",
109
110 // Historical
111 "menuitem",
112 "image"
113 ].forEach(name => {
114 test(() => {
115 const range = document.createRange();
116 const contextNode = document.createElement(name);
117 const selectedNode = document.createElement("div");
118 contextNode.appendChild(selectedNode);
119 range.selectNode(selectedNode);
120
121 range.createContextualFragment("some text");
122 }, `createContextualFragment should work even when the context is <${nam e}>`);
123 });
124
125
87 // Now that we've established basic sanity, let's do equivalence tests. Those 126 // Now that we've established basic sanity, let's do equivalence tests. Those
88 // are easier to write anyway. 127 // are easier to write anyway.
89 function testEquivalence(element1, fragment1, element2, fragment2) { 128 function testEquivalence(element1, fragment1, element2, fragment2) {
90 var range1 = element1.ownerDocument.createRange(); 129 var range1 = element1.ownerDocument.createRange();
91 range1.selectNodeContents(element1); 130 range1.selectNodeContents(element1);
92 var range2 = element2.ownerDocument.createRange(); 131 var range2 = element2.ownerDocument.createRange();
93 range2.selectNodeContents(element2); 132 range2.selectNodeContents(element2);
94 133
95 var result1 = range1.createContextualFragment(fragment1); 134 var result1 = range1.createContextualFragment(fragment1);
96 var result2 = range2.createContextualFragment(fragment2); 135 var result2 = range2.createContextualFragment(fragment2);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 ["Text nodes shouldn't be special", 170 ["Text nodes shouldn't be special",
132 document.createTextNode("?"), "<body><p>", 171 document.createTextNode("?"), "<body><p>",
133 document.createElement("div"), "<body><p>"], 172 document.createElement("div"), "<body><p>"],
134 ["Non-Element parent should not be special", 173 ["Non-Element parent should not be special",
135 comment, "<body><p>", 174 comment, "<body><p>",
136 document.createElement("div"), "<body><p>"] 175 document.createElement("div"), "<body><p>"]
137 ]; 176 ];
138 177
139 generate_tests(testEquivalence, tests); 178 generate_tests(testEquivalence, tests);
140 </script> 179 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698