blob: a3d332e63041ff673134f3ef80a457e7cab2b763 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
description(
"This test checks whether various forms of delete expression are allowed."
);
window.y = 0;
shouldBeTrue('delete x');
window.x = 0;
window.y = 0;
shouldBeTrue('delete window.x');
window.x = 0;
window.y = 0;
shouldBeTrue('delete window["x"]');
window.x = 0;
window.y = 0;
shouldBeTrue('delete (x)');
window.x = 0;
window.y = 0;
shouldBeTrue('delete (window.x)');
window.x = 0;
window.y = 0;
shouldBeTrue('delete (window["x"])');
window.x = 0;
window.y = 0;
shouldBeTrue('(y, delete x)');
window.x = 0;
window.y = 0;
shouldBeTrue('delete ((x))');
window.x = 0;
window.y = 0;
shouldBeTrue('delete ((window.x))');
window.x = 0;
window.y = 0;
shouldBeTrue('delete ((window["x"]))');
window.x = 0;
window.y = 0;
shouldBeTrue('delete (y, x)');
window.x = 0;
window.y = 0;
shouldBeTrue('delete (true ? x : y)');
window.x = 0;
window.y = 0;
shouldBeTrue('delete nonexistent');
shouldBeTrue('delete window.nonexistent');
shouldBeTrue('delete window["nonexistent"]');
shouldBeTrue('delete (nonexistent)');
shouldBeTrue('delete (window.nonexistent)');
shouldBeTrue('delete (window["nonexistent"])');
shouldBeTrue('delete "x"');
shouldBeTrue('delete (2 + 3)');
var mathCos = Math.cos;
delete Math.sin;
Math.tan = null;
// Try deleting & overwriting static properties.
shouldBe("Math.cos", "mathCos");
shouldBe("Math.sin", "undefined");
shouldBe("Math.tan", "null");
var regExpPrototypeCompile = RegExp.prototype.compile;
RegExp.prototype.test = null;
Object.preventExtensions(RegExp.prototype);
delete RegExp.prototype.exec;
// Reverse order of delete & overwrite, tests delete after preventExtensions.
shouldBe("RegExp.prototype.compile", "regExpPrototypeCompile");
shouldBe("RegExp.prototype.exec", "undefined");
shouldBe("RegExp.prototype.test", "null");
// Check that once a property is deleted its name is removed from the property name array.
delete Object.prototype.__defineSetter__;
shouldBe("Object.getOwnPropertyNames(Object.prototype).indexOf('__defineSetter__')", "-1");
|