Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Side by Side Diff: Source/bindings/core/v8/custom/V8WindowCustom.cpp

Issue 1138583002: Make Window.prototype.toString return [object Window] at all times. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: shouldBeEqualToString Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/http/tests/security/resources/cross-frame-window-to-string-test.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, targetOri gin, info[targetOriginArgIndex]); 211 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, targetOri gin, info[targetOriginArgIndex]);
212 212
213 RefPtr<SerializedScriptValue> message = SerializedScriptValueFactory::instan ce().create(info.GetIsolate(), info[0], &portArray, &arrayBufferArray, exception State); 213 RefPtr<SerializedScriptValue> message = SerializedScriptValueFactory::instan ce().create(info.GetIsolate(), info[0], &portArray, &arrayBufferArray, exception State);
214 if (exceptionState.throwIfNeeded()) 214 if (exceptionState.throwIfNeeded())
215 return; 215 return;
216 216
217 window->postMessage(message.release(), &portArray, targetOrigin, source, exc eptionState); 217 window->postMessage(message.release(), &portArray, targetOrigin, source, exc eptionState);
218 exceptionState.throwIfNeeded(); 218 exceptionState.throwIfNeeded();
219 } 219 }
220 220
221 // FIXME(fqian): returning string is cheating, and we should 221 // TODO(arv): Remove this custom method and implement Symbol.toStringTag instead .
222 // fix this by calling toString function on the receiver.
223 // However, V8 implements toString in JavaScript, which requires
224 // switching context of receiver. I consider it is dangerous.
225 void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i nfo) 222 void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i nfo)
226 { 223 {
227 v8::Local<v8::Object> domWrapper = V8Window::findInstanceInPrototypeChain(in fo.This(), info.GetIsolate()); 224 v8SetReturnValueString(info, "[object Window]", info.GetIsolate());
228 v8::Local<v8::Object> target = domWrapper.IsEmpty() ? info.This() : domWrapp er;
229 v8::Local<v8::String> value;
230 if (target->ObjectProtoToString(info.GetIsolate()->GetCurrentContext()).ToLo cal(&value))
231 v8SetReturnValue(info, value);
232 } 225 }
233 226
234 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) 227 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
235 { 228 {
236 LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder())); 229 LocalDOMWindow* impl = toLocalDOMWindow(V8Window::toImpl(info.Holder()));
237 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win dow", info.Holder(), info.GetIsolate()); 230 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win dow", info.Holder(), info.GetIsolate());
238 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) { 231 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) {
239 exceptionState.throwIfNeeded(); 232 exceptionState.throwIfNeeded();
240 return; 233 return;
241 } 234 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 { 338 {
346 return securityCheck(host); 339 return securityCheck(host);
347 } 340 }
348 341
349 bool V8Window::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t i ndex, v8::AccessType type, v8::Local<v8::Value>) 342 bool V8Window::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t i ndex, v8::AccessType type, v8::Local<v8::Value>)
350 { 343 {
351 return securityCheck(host); 344 return securityCheck(host);
352 } 345 }
353 346
354 } // namespace blink 347 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/security/resources/cross-frame-window-to-string-test.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698