Source/WebCore/ChangeLog

 12012-05-20 Kentaro Hara <haraken@chromium.org>
 2
 3 REGRESSION r110315: Event handler throws TypeError for an input element with name="arguments"
 4 https://bugs.webkit.org/show_bug.cgi?id=86991
 5
 6 Reviewed by Ojan Vafai.
 7
 8 Original Chromium bug: http://code.google.com/p/chromium/issues/detail?id=128723
 9
 10 Consider the following html:
 11
 12 <html><body><form>
 13 <input type="hidden" name="arguments"></input>
 14 <div onclick="onclicked()" id="divInsideForm">Click here</div>
 15 </form></body>
 16 <script>
 17 function onclicked() {
 18 alert("onclicked");
 19 }
 20 </script>
 21 </html>
 22
 23 If we click "Click here", JavaScript throws "Uncaught TypeError: undefined has no properties".
 24
 25 This is a regression caused by r110315. V8LazyEventListener should not use
 26 'arguments' to retrieve the execution contexts, since 'arguments' can be
 27 being overwritten by JavaScript.
 28
 29 This patch changes V8LazyEventListener so that it retrieves contexts
 30 by this.ownerDocument, this.form, and this.
 31
 32 Test: fast/forms/form-input-named-arguments.html
 33
 34 * bindings/v8/V8LazyEventListener.cpp:
 35 (WebCore::V8LazyEventListener::prepareListenerObject):
 36
1372012-05-21 Emil A Eklund <eae@chromium.org>
238
339 Move padding/margin/offset writing mode logic from RenderStyle to LengthBox

Source/WebCore/bindings/v8/V8LazyEventListener.cpp

@@void V8LazyEventListener::prepareListenerObject(ScriptExecutionContext* context)
137137 // FIXME: V8 does not allow us to programmatically create object environments so
138138 // we have to do this hack! What if m_code escapes to run arbitrary script?
139139 //
 140 // Call with 4 arguments instead of 3, pass additional null as last parameter.
 141 // By calling the function with 4 arguments, we create a setter on arguments object
 142 // which would shadow property "3" on the prototype.
140143 String code = "(function() {" \
141  "with (arguments[2]) {" \
142  "with (arguments[1]) {" \
143  "with (arguments[0]) {";
 144 "arguments[3] = function() {" \
 145 "with (this[2]) {" \
 146 "with (this[1]) {" \
 147 "with (this[0]) {";
144148 code.append("return function(");
145149 code.append(m_eventParameterName);
146150 code.append(") {");
147151 code.append(m_code);
148152 // Insert '\n' otherwise //-style comments could break the handler.
149  code.append("\n};}}}})");
 153 code.append("\n};}}}}; return arguments[3]();})");
150154 v8::Handle<v8::String> codeExternalString = v8ExternalString(code);
151155
152156 v8::Handle<v8::Script> script = V8Proxy::compileScript(codeExternalString, m_sourceURL, m_position);

LayoutTests/ChangeLog

 12012-05-20 Kentaro Hara <haraken@chromium.org>
 2
 3 REGRESSION r110315: Event handler throws TypeError for an input element with name="arguments"
 4 https://bugs.webkit.org/show_bug.cgi?id=86991
 5
 6 Reviewed by Ojan Vafai.
 7
 8 The added test checks whether an event handler is successfully invoked
 9 for an input element with name="arguments".
 10
 11 * fast/forms/form-input-named-arguments-expected.txt: Added.
 12 * fast/forms/form-input-named-arguments.html: Added.
 13
1142012-05-21 Levi Weintraub <leviw@chromium.org>
215
316 Unreviewed. More rebaselines following r117815.

LayoutTests/fast/forms/form-input-named-arguments-expected.txt

 1onclicked() is successfully called.
 2PASS successfullyParsed is true
 3
 4TEST COMPLETE
 5

LayoutTests/fast/forms/form-input-named-arguments.html

 1<!DOCTYPE html>
 2<html>
 3<head></head>
 4<body>
 5<script src="../js/resources/js-test-pre.js"></script>
 6<form>
 7<input type="hidden" name="arguments"></input>
 8<div onclick="onclicked()" id="divInsideForm"></div>
 9</form>
 10</body>
 11<script>
 12if (window.layoutTestController)
 13 layoutTestController.waitUntilDone();
 14
 15function onclicked() {
 16 debug("onclicked() is successfully called.");
 17 if (window.layoutTestController) {
 18 successfullyParsed = true;
 19 layoutTestController.notifyDone();
 20 }
 21}
 22
 23var event = document.createEvent("MouseEvents");
 24event.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
 25var div = document.getElementById("divInsideForm");
 26div.dispatchEvent(event);
 27</script>
 28<script src="../js/resources/js-test-post.js"></script>
 29</html>