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

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp

Issue 1983743002: When defining custom elements, check that the argument is a constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp
index b9a5c707fa11be748539b66dcac9edcd4d2d0dcb..6163dced4530d47532ca1639222c3e9ac9f85fd2 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.cpp
@@ -60,16 +60,19 @@ void CustomElementsRegistry::define(ScriptState* scriptState,
v8::Isolate* isolate = scriptState->isolate();
v8::Local<v8::Context> context = scriptState->context();
- // TODO(dominicc): Make this check for constructors and not just
- // functions when
- // https://bugs.chromium.org/p/v8/issues/detail?id=4993 is fixed.
v8::Local<v8::Value> constructorValue = constructorScriptValue.v8Value();
if (!constructorValue->IsFunction()) {
+ // Not even a function.
exceptionState.throwTypeError(
"constructor argument is not a constructor");
return;
}
v8::Local<v8::Object> constructor = constructorValue.As<v8::Object>();
+ if (!constructor->IsConstructor()) {
+ exceptionState.throwTypeError(
+ "constructor argument is not a constructor");
+ return;
+ }
// Raise an exception if the name is not valid.
if (!CustomElement::isValidName(name)) {
« no previous file with comments | « third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698