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

Unified Diff: Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp

Issue 98783003: Make HTMLOptionsCollection report TypeErrors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add TextTrackCue() exception handling test Created 7 years 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
Index: Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
diff --git a/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp b/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
index e0523d70703f34ca1cb4c6cee6557f4e99056f30..094bf4acc8ba176b6118dd56fbf6175bf91075ab 100644
--- a/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
+++ b/Source/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
@@ -73,23 +73,23 @@ void V8HTMLOptionsCollection::namedItemMethodCustom(const v8::FunctionCallbackIn
void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "add", "HTMLOptionsCollection", info.Holder(), info.GetIsolate());
if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) {
- setDOMException(TypeMismatchError, info.GetIsolate());
- return;
- }
- HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder());
- HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Object>(v8::Handle<v8::Object>::Cast(info[0])));
+ exceptionState.throwTypeError("The element provided was not an HTMLOptionElement.");
+ } else {
+ HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder());
+ HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Object>(v8::Handle<v8::Object>::Cast(info[0])));
- ExceptionState exceptionState(info.Holder(), info.GetIsolate());
- if (info.Length() < 2)
- imp->add(option, exceptionState);
- else {
- bool ok;
- V8TRYCATCH_VOID(int, index, toInt32(info[1], ok));
- if (!ok)
- exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::failedToExecute("add", "HTMLOptionsCollection", "The index provided could not be interpreted as an integer."));
- else
- imp->add(option, index, exceptionState);
+ if (info.Length() < 2) {
+ imp->add(option, exceptionState);
+ } else {
+ bool ok;
+ V8TRYCATCH_VOID(int, index, toInt32(info[1], ok));
+ if (!ok)
+ exceptionState.throwTypeError("The index provided could not be interpreted as an integer.");
+ else
+ imp->add(option, index, exceptionState);
+ }
}
exceptionState.throwIfNeeded();
@@ -100,10 +100,10 @@ void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::Value> v
HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder());
double v = value->NumberValue();
unsigned newLength = 0;
- ExceptionState exceptionState(info.Holder(), info.GetIsolate());
+ ExceptionState exceptionState(ExceptionState::SetterContext, "length", "HTMLOptionsCollection", info.Holder(), info.GetIsolate());
if (!std::isnan(v) && !std::isinf(v)) {
if (v < 0.0)
- exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::failedToSet("length", "HTMLOptionsCollection", "The value provided (" + String::number(v) + ") is negative. Lengths must be greater than or equal to 0."));
+ exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(v) + ") is negative. Lengths must be greater than or equal to 0.");
else if (v > static_cast<double>(UINT_MAX))
newLength = UINT_MAX;
else
« no previous file with comments | « LayoutTests/media/track/text-track-cue-constructor-expected.txt ('k') | Source/bindings/v8/custom/V8TextTrackCueCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698