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

Unified Diff: third_party/WebKit/Source/core/testing/WorkerInternals.cpp

Issue 2820193003: Worker: Raise an exception when an invalid feature number is passed to WorkerInternals::CountFeature (Closed)
Patch Set: Created 3 years, 8 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
Index: third_party/WebKit/Source/core/testing/WorkerInternals.cpp
diff --git a/third_party/WebKit/Source/core/testing/WorkerInternals.cpp b/third_party/WebKit/Source/core/testing/WorkerInternals.cpp
index 42ee53948a1e119a65f732375f22c234cb4b35fb..afc509ca9ab668448cb153b393e68c19c83241ce 100644
--- a/third_party/WebKit/Source/core/testing/WorkerInternals.cpp
+++ b/third_party/WebKit/Source/core/testing/WorkerInternals.cpp
@@ -4,6 +4,7 @@
#include "core/testing/WorkerInternals.h"
+#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ScriptState.h"
#include "core/dom/ExecutionContext.h"
#include "core/frame/Deprecation.h"
@@ -21,13 +22,25 @@ OriginTrialsTest* WorkerInternals::originTrialsTest() const {
}
void WorkerInternals::countFeature(ScriptState* script_state,
- uint32_t feature) {
+ uint32_t feature,
+ ExceptionState& exception_state) {
+ if (UseCounter::kNumberOfFeatures <= feature) {
+ exception_state.ThrowTypeError(
+ "The given feature does not exist in UseCounter::Feature.");
+ return;
+ }
UseCounter::Count(ExecutionContext::From(script_state),
static_cast<UseCounter::Feature>(feature));
}
void WorkerInternals::countDeprecation(ScriptState* script_state,
- uint32_t feature) {
+ uint32_t feature,
+ ExceptionState& exception_state) {
+ if (UseCounter::kNumberOfFeatures <= feature) {
+ exception_state.ThrowTypeError(
+ "The given feature does not exist in UseCounter::Feature.");
+ return;
+ }
Deprecation::CountDeprecation(ExecutionContext::From(script_state),
static_cast<UseCounter::Feature>(feature));
}
« no previous file with comments | « third_party/WebKit/Source/core/testing/WorkerInternals.h ('k') | third_party/WebKit/Source/core/testing/WorkerInternals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698