|
Lines 137-152
void V8LazyEventListener::prepareListenerObject(ScriptExecutionContext* context)
a/Source/WebCore/bindings/v8/V8LazyEventListener.cpp_sec1
|
| 137 |
// FIXME: V8 does not allow us to programmatically create object environments so |
137 |
// FIXME: V8 does not allow us to programmatically create object environments so |
| 138 |
// we have to do this hack! What if m_code escapes to run arbitrary script? |
138 |
// we have to do this hack! What if m_code escapes to run arbitrary script? |
| 139 |
// |
139 |
// |
|
|
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. |
| 140 |
String code = "(function() {" \ |
143 |
String code = "(function() {" \ |
| 141 |
"with (arguments[2]) {" \ |
144 |
"arguments[3] = function() {" \ |
| 142 |
"with (arguments[1]) {" \ |
145 |
"with (this[2]) {" \ |
| 143 |
"with (arguments[0]) {"; |
146 |
"with (this[1]) {" \ |
|
|
147 |
"with (this[0]) {"; |
| 144 |
code.append("return function("); |
148 |
code.append("return function("); |
| 145 |
code.append(m_eventParameterName); |
149 |
code.append(m_eventParameterName); |
| 146 |
code.append(") {"); |
150 |
code.append(") {"); |
| 147 |
code.append(m_code); |
151 |
code.append(m_code); |
| 148 |
// Insert '\n' otherwise //-style comments could break the handler. |
152 |
// Insert '\n' otherwise //-style comments could break the handler. |
| 149 |
code.append("\n};}}}})"); |
153 |
code.append("\n};}}}}; return arguments[3]();})"); |
| 150 |
v8::Handle<v8::String> codeExternalString = v8ExternalString(code); |
154 |
v8::Handle<v8::String> codeExternalString = v8ExternalString(code); |
| 151 |
|
155 |
|
| 152 |
v8::Handle<v8::Script> script = V8Proxy::compileScript(codeExternalString, m_sourceURL, m_position); |
156 |
v8::Handle<v8::Script> script = V8Proxy::compileScript(codeExternalString, m_sourceURL, m_position); |