| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 v8SetReturnValue(info, timerId); | 153 v8SetReturnValue(info, timerId); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void V8Window::eventAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Val
ue>& info) | 156 void V8Window::eventAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Val
ue>& info) |
| 157 { | 157 { |
| 158 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
Window::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate()))
); | 158 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
Window::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate()))
); |
| 159 if (holder.IsEmpty()) | 159 if (holder.IsEmpty()) |
| 160 return; | 160 return; |
| 161 | 161 |
| 162 Frame* frame = V8Window::toNative(holder)->frame(); | 162 Frame* frame = V8Window::toNative(holder)->frame(); |
| 163 ExceptionState es(info.GetIsolate()); | 163 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 164 if (!BindingSecurity::shouldAllowAccessToFrame(frame, es)) { | 164 if (!BindingSecurity::shouldAllowAccessToFrame(frame, es)) { |
| 165 es.throwIfNeeded(); | 165 es.throwIfNeeded(); |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 | 168 |
| 169 ASSERT(frame); | 169 ASSERT(frame); |
| 170 v8::Local<v8::Context> context = frame->script().currentWorldContext(); | 170 v8::Local<v8::Context> context = frame->script().currentWorldContext(); |
| 171 if (context.IsEmpty()) | 171 if (context.IsEmpty()) |
| 172 return; | 172 return; |
| 173 | 173 |
| 174 v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(info.GetIso
late()); | 174 v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(info.GetIso
late()); |
| 175 v8::Handle<v8::Value> jsEvent = context->Global()->GetHiddenValue(eventSymbo
l); | 175 v8::Handle<v8::Value> jsEvent = context->Global()->GetHiddenValue(eventSymbo
l); |
| 176 if (jsEvent.IsEmpty()) | 176 if (jsEvent.IsEmpty()) |
| 177 return; | 177 return; |
| 178 v8SetReturnValue(info, jsEvent); | 178 v8SetReturnValue(info, jsEvent); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void V8Window::eventAttributeSetterCustom(v8::Local<v8::Value> value, const v8::
PropertyCallbackInfo<void>& info) | 181 void V8Window::eventAttributeSetterCustom(v8::Local<v8::Value> value, const v8::
PropertyCallbackInfo<void>& info) |
| 182 { | 182 { |
| 183 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
Window::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate()))
); | 183 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(V8
Window::GetTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate()))
); |
| 184 if (holder.IsEmpty()) | 184 if (holder.IsEmpty()) |
| 185 return; | 185 return; |
| 186 | 186 |
| 187 Frame* frame = V8Window::toNative(holder)->frame(); | 187 Frame* frame = V8Window::toNative(holder)->frame(); |
| 188 ExceptionState es(info.GetIsolate()); | 188 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 189 if (!BindingSecurity::shouldAllowAccessToFrame(frame, es)) { | 189 if (!BindingSecurity::shouldAllowAccessToFrame(frame, es)) { |
| 190 es.throwIfNeeded(); | 190 es.throwIfNeeded(); |
| 191 return; | 191 return; |
| 192 } | 192 } |
| 193 | 193 |
| 194 ASSERT(frame); | 194 ASSERT(frame); |
| 195 v8::Local<v8::Context> context = frame->script().currentWorldContext(); | 195 v8::Local<v8::Context> context = frame->script().currentWorldContext(); |
| 196 if (context.IsEmpty()) | 196 if (context.IsEmpty()) |
| 197 return; | 197 return; |
| 198 | 198 |
| 199 v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(info.GetIso
late()); | 199 v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(info.GetIso
late()); |
| 200 context->Global()->SetHiddenValue(eventSymbol, value); | 200 context->Global()->SetHiddenValue(eventSymbol, value); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void V8Window::openerAttributeSetterCustom(v8::Local<v8::Value> value, const v8:
:PropertyCallbackInfo<void>& info) | 203 void V8Window::openerAttributeSetterCustom(v8::Local<v8::Value> value, const v8:
:PropertyCallbackInfo<void>& info) |
| 204 { | 204 { |
| 205 DOMWindow* imp = V8Window::toNative(info.Holder()); | 205 DOMWindow* imp = V8Window::toNative(info.Holder()); |
| 206 ExceptionState es(info.GetIsolate()); | 206 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 207 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) { | 207 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) { |
| 208 es.throwIfNeeded(); | 208 es.throwIfNeeded(); |
| 209 return; | 209 return; |
| 210 } | 210 } |
| 211 | 211 |
| 212 // Opener can be shadowed if it is in the same domain. | 212 // Opener can be shadowed if it is in the same domain. |
| 213 // Have a special handling of null value to behave | 213 // Have a special handling of null value to behave |
| 214 // like Firefox. See bug http://b/1224887 & http://b/791706. | 214 // like Firefox. See bug http://b/1224887 & http://b/791706. |
| 215 if (value->IsNull()) { | 215 if (value->IsNull()) { |
| 216 // imp->frame() cannot be null, | 216 // imp->frame() cannot be null, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, targetOrigin, info[targetOriginArgIndex]); | 272 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, targetOrigin, info[targetOriginArgIndex]); |
| 273 | 273 |
| 274 bool didThrow = false; | 274 bool didThrow = false; |
| 275 RefPtr<SerializedScriptValue> message = | 275 RefPtr<SerializedScriptValue> message = |
| 276 SerializedScriptValue::create(info[0], &portArray, &arrayBufferArray, di
dThrow, info.GetIsolate()); | 276 SerializedScriptValue::create(info[0], &portArray, &arrayBufferArray, di
dThrow, info.GetIsolate()); |
| 277 if (didThrow) | 277 if (didThrow) |
| 278 return; | 278 return; |
| 279 | 279 |
| 280 ExceptionState es(info.GetIsolate()); | 280 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 281 window->postMessage(message.release(), &portArray, targetOrigin, source, es)
; | 281 window->postMessage(message.release(), &portArray, targetOrigin, source, es)
; |
| 282 es.throwIfNeeded(); | 282 es.throwIfNeeded(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 // FIXME(fqian): returning string is cheating, and we should | 285 // FIXME(fqian): returning string is cheating, and we should |
| 286 // fix this by calling toString function on the receiver. | 286 // fix this by calling toString function on the receiver. |
| 287 // However, V8 implements toString in JavaScript, which requires | 287 // However, V8 implements toString in JavaScript, which requires |
| 288 // switching context of receiver. I consider it is dangerous. | 288 // switching context of receiver. I consider it is dangerous. |
| 289 void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) | 289 void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) |
| 290 { | 290 { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 334 } |
| 335 | 335 |
| 336 static void setUpDialog(DOMWindow* dialog, void* handler) | 336 static void setUpDialog(DOMWindow* dialog, void* handler) |
| 337 { | 337 { |
| 338 static_cast<DialogHandler*>(handler)->dialogCreated(dialog); | 338 static_cast<DialogHandler*>(handler)->dialogCreated(dialog); |
| 339 } | 339 } |
| 340 | 340 |
| 341 void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 341 void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
| 342 { | 342 { |
| 343 DOMWindow* impl = V8Window::toNative(info.Holder()); | 343 DOMWindow* impl = V8Window::toNative(info.Holder()); |
| 344 ExceptionState es(info.GetIsolate()); | 344 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 345 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), es)) { | 345 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), es)) { |
| 346 es.throwIfNeeded(); | 346 es.throwIfNeeded(); |
| 347 return; | 347 return; |
| 348 } | 348 } |
| 349 | 349 |
| 350 // FIXME: Handle exceptions properly. | 350 // FIXME: Handle exceptions properly. |
| 351 String urlString = toWebCoreStringWithUndefinedOrNullCheck(info[0]); | 351 String urlString = toWebCoreStringWithUndefinedOrNullCheck(info[0]); |
| 352 DialogHandler handler(info[1]); | 352 DialogHandler handler(info[1]); |
| 353 String dialogFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(info[2
]); | 353 String dialogFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(info[2
]); |
| 354 | 354 |
| 355 impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(), fi
rstDOMWindow(), setUpDialog, &handler); | 355 impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(), fi
rstDOMWindow(), setUpDialog, &handler); |
| 356 | 356 |
| 357 v8SetReturnValue(info, handler.returnValue(info.GetIsolate())); | 357 v8SetReturnValue(info, handler.returnValue(info.GetIsolate())); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) | 360 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 361 { | 361 { |
| 362 DOMWindow* impl = V8Window::toNative(info.Holder()); | 362 DOMWindow* impl = V8Window::toNative(info.Holder()); |
| 363 ExceptionState es(info.GetIsolate()); | 363 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 364 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), es)) { | 364 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), es)) { |
| 365 es.throwIfNeeded(); | 365 es.throwIfNeeded(); |
| 366 return; | 366 return; |
| 367 } | 367 } |
| 368 | 368 |
| 369 // FIXME: Handle exceptions properly. | 369 // FIXME: Handle exceptions properly. |
| 370 String urlString = toWebCoreStringWithUndefinedOrNullCheck(info[0]); | 370 String urlString = toWebCoreStringWithUndefinedOrNullCheck(info[0]); |
| 371 AtomicString frameName = (info[1]->IsUndefined() || info[1]->IsNull()) ? "_b
lank" : toWebCoreAtomicString(info[1]); | 371 AtomicString frameName = (info[1]->IsUndefined() || info[1]->IsNull()) ? "_b
lank" : toWebCoreAtomicString(info[1]); |
| 372 String windowFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(info[2
]); | 372 String windowFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(info[2
]); |
| 373 | 373 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 v8SetReturnValueFast(info, items.release(), window); | 416 v8SetReturnValueFast(info, items.release(), window); |
| 417 return; | 417 return; |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 | 422 |
| 423 | 423 |
| 424 void V8Window::setTimeoutMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) | 424 void V8Window::setTimeoutMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 425 { | 425 { |
| 426 ExceptionState es(info.GetIsolate()); | 426 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 427 WindowSetTimeoutImpl(info, true, es); | 427 WindowSetTimeoutImpl(info, true, es); |
| 428 es.throwIfNeeded(); | 428 es.throwIfNeeded(); |
| 429 } | 429 } |
| 430 | 430 |
| 431 | 431 |
| 432 void V8Window::setIntervalMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) | 432 void V8Window::setIntervalMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) |
| 433 { | 433 { |
| 434 ExceptionState es(info.GetIsolate()); | 434 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 435 WindowSetTimeoutImpl(info, false, es); | 435 WindowSetTimeoutImpl(info, false, es); |
| 436 es.throwIfNeeded(); | 436 es.throwIfNeeded(); |
| 437 } | 437 } |
| 438 | 438 |
| 439 bool V8Window::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8
::Value> key, v8::AccessType type, v8::Local<v8::Value>) | 439 bool V8Window::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8
::Value> key, v8::AccessType type, v8::Local<v8::Value>) |
| 440 { | 440 { |
| 441 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 441 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 442 v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8Window:
:GetTemplate(isolate, worldTypeInMainThread(isolate))); | 442 v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8Window:
:GetTemplate(isolate, worldTypeInMainThread(isolate))); |
| 443 if (window.IsEmpty()) | 443 if (window.IsEmpty()) |
| 444 return false; // the frame is gone. | 444 return false; // the frame is gone. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 v8::Handle<v8::Context> context = frame->script().currentWorldContext(); | 542 v8::Handle<v8::Context> context = frame->script().currentWorldContext(); |
| 543 if (context.IsEmpty()) | 543 if (context.IsEmpty()) |
| 544 return v8Undefined(); | 544 return v8Undefined(); |
| 545 | 545 |
| 546 v8::Handle<v8::Object> global = context->Global(); | 546 v8::Handle<v8::Object> global = context->Global(); |
| 547 ASSERT(!global.IsEmpty()); | 547 ASSERT(!global.IsEmpty()); |
| 548 return global; | 548 return global; |
| 549 } | 549 } |
| 550 | 550 |
| 551 } // namespace WebCore | 551 } // namespace WebCore |
| OLD | NEW |