diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 6b356f8ccfd1467c9d90e50df8c63a155c1bee82..1a7c1ed894d9001a79713ce1b76a47906a4f768f 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,16 @@ +2007-11-12 Geoffrey Garen + + Rubber-stamped by Oliver Hunt. + + Landing a few layout tests from http://bugs.webkit.org/show_bug.cgi?id=14868 + Import variable lookup optimizations from KJS + + * fast/js/kde/arguments-scope-expected.txt: Added. + * fast/js/kde/arguments-scope.html: Added. + * fast/js/kde/resources/arguments-scope.js: Added. + * fast/js/kde/resources/scope.js: + * fast/js/kde/scope-expected.txt: + 2007-11-11 Dan Bernstein Reviewed by Adam Roben. diff --git a/LayoutTests/fast/js/kde/arguments-scope-expected.txt b/LayoutTests/fast/js/kde/arguments-scope-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..07fea75a4b5f873c0ac909ea8019402c303e0998 --- /dev/null +++ b/LayoutTests/fast/js/kde/arguments-scope-expected.txt @@ -0,0 +1,15 @@ +KDE JS Test + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS test0 +PASS test1 +PASS test2 +PASS test3 +PASS test4.(1) +PASS test4.(2) +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/js/kde/arguments-scope.html b/LayoutTests/fast/js/kde/arguments-scope.html new file mode 100644 index 0000000000000000000000000000000000000000..e88c417f02e9df31ae8d3d30aa58b12b588c6a6c --- /dev/null +++ b/LayoutTests/fast/js/kde/arguments-scope.html @@ -0,0 +1,16 @@ + + + + + + + +

+
+ + + + + diff --git a/LayoutTests/fast/js/kde/resources/arguments-scope.js b/LayoutTests/fast/js/kde/resources/arguments-scope.js new file mode 100644 index 0000000000000000000000000000000000000000..1506751724e71ed14b7de672a81c3d07ec3231e8 --- /dev/null +++ b/LayoutTests/fast/js/kde/resources/arguments-scope.js @@ -0,0 +1,51 @@ +// We can't use normal shouldBe here, since they'd eval in the wrong context... + +function shouldBeOfType(msg, val, type) { + if (typeof(val) != type) + testFailed(msg + ": value has type " + typeof(val) + " , not:" + type); + else + testPassed(msg); +} + +function test0() { + var arguments; + // var execution should not overwrite something that was + // in scope beforehand -- e.g. the arguments thing + shouldBeOfType("test0", arguments, 'object'); + } + +function test1() { + // No need to undef-initialize something in scope already! + shouldBeOfType("test1", arguments, 'object'); + var arguments; +} + +function test2(arguments) { + // Formals OTOH can overwrite the args object + shouldBeOfType("test2", arguments, 'number'); +} + + +function test3() { + // Ditto for functions.. + shouldBeOfType("test3", arguments, 'function'); + function arguments() {} +} + +function test4() { + // Here, the -declaration- part of the var below should have no + // effect.. + shouldBeOfType('test4.(1)', arguments, 'object'); + var arguments = 4; + // .. but the assignment shoud just happen + shouldBeOfType('test4.(2)', arguments, 'number'); +} + + +test0(); +test1(); +test2(42); +test3(); +test4(); + +var successfullyParsed = true; diff --git a/LayoutTests/fast/js/kde/resources/scope.js b/LayoutTests/fast/js/kde/resources/scope.js index 1aa3720f5775cdbbb0320305977dcc3908ad6a0f..acf315bd3a31ff30a21443964fb47b30d3ed734d 100644 --- a/LayoutTests/fast/js/kde/resources/scope.js +++ b/LayoutTests/fast/js/kde/resources/scope.js @@ -6,4 +6,31 @@ with (b) { } shouldBe("f(2)", "22"); -successfullyParsed = true + +var OBJECT = new MyObject( "hello" ); +function MyObject(value) { + this.value = value; + this.toString = new Function( "return this.value+''" ); + return this; +} +shouldBe("OBJECT.toString()", "'hello'"); +var s; +with (OBJECT) { + s = toString(); +} +shouldBe("s", "'hello'"); + + +// Make sure that for ... in reevaluates the scoping every time! +P = { foo : 1, bar : 2, baz : 3 } + +function testForIn() { + for (g in P) { + eval("var g;") //Change the scope of g half-ways through the loop + } +} + +testForIn(); +shouldBe("g", "'foo'"); //Before the eval, g was in outer scope, but not after! + +var successfullyParsed = true; diff --git a/LayoutTests/fast/js/kde/scope-expected.txt b/LayoutTests/fast/js/kde/scope-expected.txt index 141c7bfda4d49e761ea2a9d0d4dd9dce749d2332..a33e874faa0e57d4502a4a104ad5f23f2345290a 100644 --- a/LayoutTests/fast/js/kde/scope-expected.txt +++ b/LayoutTests/fast/js/kde/scope-expected.txt @@ -4,6 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE PASS f(2) is 22 +PASS OBJECT.toString() is 'hello' +PASS s is 'hello' +PASS g is 'foo' PASS successfullyParsed is true TEST COMPLETE