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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Comment-Text-constructor.js

Issue 1529523002: Import dom/ from web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak W3CImportExpectations Created 5 years 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 function test_constructor(ctor) {
2 test(function() {
3 var object = new window[ctor]();
4 assert_equals(Object.getPrototypeOf(object),
5 window[ctor].prototype, "Prototype chain: " + ctor);
6 assert_equals(Object.getPrototypeOf(Object.getPrototypeOf(object)),
7 CharacterData.prototype, "Prototype chain: CharacterData");
8 assert_equals(Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototyp eOf(object))),
9 Node.prototype, "Prototype chain: Node");
10 }, "new " + ctor + "(): prototype chain");
11
12 test(function() {
13 var object = new window[ctor]();
14 assert_true(object instanceof Node, "Should be a Node");
15 assert_true(object instanceof CharacterData, "Should be a CharacterData");
16 assert_true(object instanceof window[ctor], "Should be a " + ctor);
17 }, "new " + ctor + "(): instanceof");
18
19 test(function() {
20 var object = new window[ctor]();
21 assert_equals(object.data, "");
22 assert_equals(object.nodeValue, "");
23 assert_equals(object.ownerDocument, document);
24 }, "new " + ctor + "(): no arguments");
25
26 var arguments = [
27 [undefined, ""],
28 [null, "null"],
29 [42, "42"],
30 ["", ""],
31 ["-", "-"],
32 ["--", "--"],
33 ["-->", "-->"],
34 ["<!--", "<!--"],
35 ["\u0000", "\u0000"],
36 ["\u0000test", "\u0000test"],
37 ["&amp;", "&amp;"],
38 ];
39
40 arguments.forEach(function(a) {
41 var argument = a[0], expected = a[1];
42 test(function() {
43 var object = new window[ctor](argument);
44 assert_equals(object.data, expected);
45 assert_equals(object.nodeValue, expected);
46 assert_equals(object.ownerDocument, document);
47 }, "new " + ctor + "(): " + format_value(argument));
48 });
49
50 test(function() {
51 var called = [];
52 var object = new window[ctor]({
53 toString: function() {
54 called.push("first");
55 return "text";
56 }
57 }, {
58 toString: function() {
59 called.push("second");
60 assert_unreached("Should not look at the second argument.");
61 }
62 });
63 assert_equals(object.data, "text");
64 assert_equals(object.nodeValue, "text");
65 assert_equals(object.ownerDocument, document);
66 assert_array_equals(called, ["first"]);
67 }, "new " + ctor + "(): two arguments")
68
69 async_test("new " + ctor + "() should get the correct ownerDocument across glo bals").step(function() {
70 var iframe = document.createElement("iframe");
71 iframe.onload = this.step_func_done(function() {
72 var object = new iframe.contentWindow[ctor]();
73 assert_equals(object.ownerDocument, iframe.contentDocument);
74 });
75 document.body.appendChild(iframe);
76 });
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698