Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / script-tests / cross-frame-really-bad-time.js
blobbd69e2fc3d12ea03ebbcd7e210ea688b8be08fb0
1 description(
2 "Tests that having a bad time has correct cross frame behavior, if an instance object is created in a different global object than the affected prototype."
3 );
5 if (window.testRunner)
6 testRunner.waitUntilDone();
8 var ouches = 0;
10 function Cons() { }
12 var array;
14 function foo() {
15 array = new Cons();
16 array.length = 10;
17 for (var i = 0; i < 10; i+=2)
18 array[i] = 42;
21 function evil() {
22 for (var i = 0; i < 10; i+=2)
23 Cons.prototype.__defineSetter__(i + 1, function() { ouches++; });
26 function bar() {
27 for (var i = 0; i < 10; i+=2)
28 array[i + 1] = 63;
31 function done() {
32 var string = Array.prototype.join.apply(array, [","]);
33 debug("Array is: " + string);
34 if (string == "42,,42,,42,,42,,42,")
35 testPassed("Array has holes in odd numbered entries.");
36 else
37 testFailed("Array does not have the required holes.");
39 if (ouches == 5)
40 testPassed("Got 5 ouches.");
41 else
42 testFailed("Did not get 5 ouches. Got " + ouches + " + instead.");
44 if (testRunner)
45 testRunner.notifyDone();
48 var frame = document.getElementById("myframe");
50 frame.contentDocument.open();
51 frame.contentDocument.write(
52 "<!DOCTYPE html>\n<html><body><script type=\"text/javascript\">\n" +
53 "window.parent.Cons.prototype = {};\n" +
54 "window.parent.foo();\n" +
55 "window.parent.evil();\n" +
56 "window.parent.bar();\n" +
57 "window.parent.done();\n" +
58 "</script></body></html>");
59 frame.contentDocument.close();