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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/common/stringifiers.js

Issue 2015623004: Import wpt@ed94c51f3dfaa5ff4c9c311add1a560408059c51 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
(Empty)
1 // Tests <http://heycam.github.io/webidl/#es-stringifier>.
2 function test_stringifier_attribute(aObject, aAttribute, aIsUnforgeable) {
3 // Step 1.
4 test(function() {
5 [null, undefined].forEach(function(v) {
6 assert_throws(new TypeError(), function() {
7 aObject.toString.call(v);
8 });
9 });
10 });
11
12 // TODO Step 2: security check.
13
14 // Step 3.
15 test(function() {
16 assert_false("Window" in window && aObject instanceof window.Window);
17 [{}, window].forEach(function(v) {
18 assert_throws(new TypeError(), function() {
19 aObject.toString.call(v)
20 });
21 });
22 });
23
24 // Step 4-6.
25 var expected_value;
26 test(function() {
27 expected_value = aObject[aAttribute];
28 assert_equals(aObject[aAttribute], expected_value,
29 "The attribute " + aAttribute + " should be pure.");
30 });
31
32 var test_error = { name: "test" };
33 test(function() {
34 if (!aIsUnforgeable) {
35 Object.defineProperty(aObject, aAttribute, {
36 configurable: true,
37 get: function() { throw test_error; }
38 });
39 }
40 assert_equals(aObject.toString(), expected_value);
41 });
42
43 test(function() {
44 if (!aIsUnforgeable) {
45 Object.defineProperty(aObject, aAttribute, {
46 configurable: true,
47 value: { toString: function() { throw test_error; } }
48 });
49 }
50 assert_equals(aObject.toString(), expected_value);
51 });
52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698