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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/resources/testharness-helpers.js

Issue 1936533003: Layout Tests: Remove assert_will_be_idl_attribute() helper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused import Created 4 years, 7 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 /* 1 /*
2 * testharness-helpers contains various useful extensions to testharness.js to 2 * testharness-helpers contains various useful extensions to testharness.js to
3 * allow them to be used across multiple tests before they have been 3 * allow them to be used across multiple tests before they have been
4 * upstreamed. This file is intended to be usable from both document and worker 4 * upstreamed. This file is intended to be usable from both document and worker
5 * environments, so code should for example not rely on the DOM. 5 * environments, so code should for example not rely on the DOM.
6 */ 6 */
7 7
8 // Returns a promise that fulfills after the provided |promise| is fulfilled. 8 // Returns a promise that fulfills after the provided |promise| is fulfilled.
9 // The |test| succeeds only if |promise| rejects with an exception matching 9 // The |test| succeeds only if |promise| rejects with an exception matching
10 // |code|. Accepted values for |code| follow those accepted for assert_throws(). 10 // |code|. Accepted values for |code| follow those accepted for assert_throws().
(...skipping 14 matching lines...) Expand all
25 function() { 25 function() {
26 throw 'assert_promise_rejects: ' + description + ' Promise did not reject. '; 26 throw 'assert_promise_rejects: ' + description + ' Promise did not reject. ';
27 }, 27 },
28 function(e) { 28 function(e) {
29 if (code !== undefined) { 29 if (code !== undefined) {
30 assert_throws(code, function() { throw e; }, description); 30 assert_throws(code, function() { throw e; }, description);
31 } 31 }
32 }); 32 });
33 } 33 }
34 34
35 // Asserts that |object| that is an instance of some interface has the attribute
36 // |attribute_name| following the conditions specified by WebIDL, but it's
37 // acceptable that the attribute |attribute_name| is an own property of the
38 // object because we're in the middle of moving the attribute to a prototype
39 // chain. Once we complete the transition to prototype chains,
40 // assert_will_be_idl_attribute must be replaced with assert_idl_attribute
41 // defined in testharness.js.
42 //
43 // FIXME: Remove assert_will_be_idl_attribute once we complete the transition
44 // of moving the DOM attributes to prototype chains. (http://crbug.com/43394)
45 function assert_will_be_idl_attribute(object, attribute_name, description) {
46 assert_true(typeof object === "object", description);
47
48 assert_true("hasOwnProperty" in object, description);
49
50 // Do not test if |attribute_name| is not an own property because
51 // |attribute_name| is in the middle of the transition to a prototype
52 // chain. (http://crbug.com/43394)
53
54 assert_true(attribute_name in object, description);
55 }
56
57 // Stringifies a DOM object. This function stringifies not only own properties 35 // Stringifies a DOM object. This function stringifies not only own properties
58 // but also DOM attributes which are on a prototype chain. Note that 36 // but also DOM attributes which are on a prototype chain. Note that
59 // JSON.stringify only stringifies own properties. 37 // JSON.stringify only stringifies own properties.
60 function stringifyDOMObject(object) 38 function stringifyDOMObject(object)
61 { 39 {
62 function deepCopy(src) { 40 function deepCopy(src) {
63 if (typeof src != "object") 41 if (typeof src != "object")
64 return src; 42 return src;
65 var dst = Array.isArray(src) ? [] : {}; 43 var dst = Array.isArray(src) ? [] : {};
66 for (var property in src) { 44 for (var property in src) {
67 dst[property] = deepCopy(src[property]); 45 dst[property] = deepCopy(src[property]);
68 } 46 }
69 return dst; 47 return dst;
70 } 48 }
71 return JSON.stringify(deepCopy(object)); 49 return JSON.stringify(deepCopy(object));
72 } 50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698