Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / script-tests / delete-syntax.js
blobbc5da72cdc94876191c45280c77329b7de45f0b3
1 description(
2 "This test checks whether various forms of delete expression are allowed."
3 );
5 window.y = 0;
7 shouldBeTrue('delete x');
8 window.x = 0;
9 window.y = 0;
10 shouldBeTrue('delete window.x');
11 window.x = 0;
12 window.y = 0;
13 shouldBeTrue('delete window["x"]');
14 window.x = 0;
15 window.y = 0;
16 shouldBeTrue('delete (x)');
17 window.x = 0;
18 window.y = 0;
19 shouldBeTrue('delete (window.x)');
20 window.x = 0;
21 window.y = 0;
22 shouldBeTrue('delete (window["x"])');
23 window.x = 0;
24 window.y = 0;
25 shouldBeTrue('(y, delete x)');
26 window.x = 0;
27 window.y = 0;
28 shouldBeTrue('delete ((x))');
29 window.x = 0;
30 window.y = 0;
31 shouldBeTrue('delete ((window.x))');
32 window.x = 0;
33 window.y = 0;
34 shouldBeTrue('delete ((window["x"]))');
35 window.x = 0;
36 window.y = 0;
37 shouldBeTrue('delete (y, x)');
38 window.x = 0;
39 window.y = 0;
40 shouldBeTrue('delete (true ? x : y)');
41 window.x = 0;
42 window.y = 0;
44 shouldBeTrue('delete nonexistent');
45 shouldBeTrue('delete window.nonexistent');
46 shouldBeTrue('delete window["nonexistent"]');
47 shouldBeTrue('delete (nonexistent)');
48 shouldBeTrue('delete (window.nonexistent)');
49 shouldBeTrue('delete (window["nonexistent"])');
51 shouldBeTrue('delete "x"');
52 shouldBeTrue('delete (2 + 3)');
54 var mathCos = Math.cos;
55 delete Math.sin;
56 Math.tan = null;
57 // Try deleting & overwriting static properties.
58 shouldBe("Math.cos", "mathCos");
59 shouldBe("Math.sin", "undefined");
60 shouldBe("Math.tan", "null");
62 var regExpPrototypeCompile = RegExp.prototype.compile;
63 RegExp.prototype.test = null;
64 Object.preventExtensions(RegExp.prototype);
65 delete RegExp.prototype.exec;
66 // Reverse order of delete & overwrite, tests delete after preventExtensions.
67 shouldBe("RegExp.prototype.compile", "regExpPrototypeCompile");
68 shouldBe("RegExp.prototype.exec", "undefined");
69 shouldBe("RegExp.prototype.test", "null");
71 // Check that once a property is deleted its name is removed from the property name array.
72 delete Object.prototype.__defineSetter__;
73 shouldBe("Object.getOwnPropertyNames(Object.prototype).indexOf('__defineSetter__')", "-1");
75 delete navigator.appCodeName;
76 delete Navigator.prototype.appCodeName;
77 var navigatorPropertyNames = getAllPropertyNames(navigator);
78 var expectedPropertyNames = [
79 "appName",
80 "appVersion",
81 "language",
82 "userAgent",
83 "platform",
84 "plugins",
85 "mimeTypes",
86 "product",
87 "productSub",
88 "vendor",
89 "vendorSub",
90 "cookieEnabled",
91 "onLine"
94 for (var i = 0; i < expectedPropertyNames.length; ++i)
95 shouldBeTrue("navigatorPropertyNames.indexOf('" + expectedPropertyNames[i] +"') != -1");