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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/testing/WorkerInternals.h" 5 #include "core/testing/WorkerInternals.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h"
7 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
8 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
9 #include "core/frame/Deprecation.h" 10 #include "core/frame/Deprecation.h"
10 #include "core/frame/UseCounter.h" 11 #include "core/frame/UseCounter.h"
11 #include "core/testing/OriginTrialsTest.h" 12 #include "core/testing/OriginTrialsTest.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 WorkerInternals::~WorkerInternals() {} 16 WorkerInternals::~WorkerInternals() {}
16 17
17 WorkerInternals::WorkerInternals() {} 18 WorkerInternals::WorkerInternals() {}
18 19
19 OriginTrialsTest* WorkerInternals::originTrialsTest() const { 20 OriginTrialsTest* WorkerInternals::originTrialsTest() const {
20 return OriginTrialsTest::Create(); 21 return OriginTrialsTest::Create();
21 } 22 }
22 23
23 void WorkerInternals::countFeature(ScriptState* script_state, 24 void WorkerInternals::countFeature(ScriptState* script_state,
24 uint32_t feature) { 25 uint32_t feature,
26 ExceptionState& exception_state) {
27 if (UseCounter::kNumberOfFeatures <= feature) {
28 exception_state.ThrowTypeError(
29 "The given feature does not exist in UseCounter::Feature.");
30 return;
31 }
25 UseCounter::Count(ExecutionContext::From(script_state), 32 UseCounter::Count(ExecutionContext::From(script_state),
26 static_cast<UseCounter::Feature>(feature)); 33 static_cast<UseCounter::Feature>(feature));
27 } 34 }
28 35
29 void WorkerInternals::countDeprecation(ScriptState* script_state, 36 void WorkerInternals::countDeprecation(ScriptState* script_state,
30 uint32_t feature) { 37 uint32_t feature,
38 ExceptionState& exception_state) {
39 if (UseCounter::kNumberOfFeatures <= feature) {
40 exception_state.ThrowTypeError(
41 "The given feature does not exist in UseCounter::Feature.");
42 return;
43 }
31 Deprecation::CountDeprecation(ExecutionContext::From(script_state), 44 Deprecation::CountDeprecation(ExecutionContext::From(script_state),
32 static_cast<UseCounter::Feature>(feature)); 45 static_cast<UseCounter::Feature>(feature));
33 } 46 }
34 47
35 void WorkerInternals::collectGarbage(ScriptState* script_state) { 48 void WorkerInternals::collectGarbage(ScriptState* script_state) {
36 script_state->GetIsolate()->RequestGarbageCollectionForTesting( 49 script_state->GetIsolate()->RequestGarbageCollectionForTesting(
37 v8::Isolate::kFullGarbageCollection); 50 v8::Isolate::kFullGarbageCollection);
38 } 51 }
39 52
40 } // namespace blink 53 } // namespace blink
OLDNEW
« 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