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

Unified Diff: Source/bindings/core/v8/custom/V8WindowCustom.cpp

Issue 1163943002: Revert of Make Window.prototype.toString return [object Window] at all times. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/custom/V8WindowCustom.cpp
diff --git a/Source/bindings/core/v8/custom/V8WindowCustom.cpp b/Source/bindings/core/v8/custom/V8WindowCustom.cpp
index 5af2203cbf40bc00d14d517ac9ff96c88dea094e..f2d3ecc95104851b0406ae4abc62cb7a0a550285 100644
--- a/Source/bindings/core/v8/custom/V8WindowCustom.cpp
+++ b/Source/bindings/core/v8/custom/V8WindowCustom.cpp
@@ -218,10 +218,17 @@
exceptionState.throwIfNeeded();
}
-// TODO(arv): Remove this custom method and implement Symbol.toStringTag instead.
+// FIXME(fqian): returning string is cheating, and we should
+// fix this by calling toString function on the receiver.
+// However, V8 implements toString in JavaScript, which requires
+// switching context of receiver. I consider it is dangerous.
void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- v8SetReturnValueString(info, "[object Window]", info.GetIsolate());
+ v8::Local<v8::Object> domWrapper = V8Window::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
+ v8::Local<v8::Object> target = domWrapper.IsEmpty() ? info.This() : domWrapper;
+ v8::Local<v8::String> value;
+ if (target->ObjectProtoToString(info.GetIsolate()->GetCurrentContext()).ToLocal(&value))
+ v8SetReturnValue(info, value);
}
void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
« 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