| Index: third_party/WebKit/Source/core/testing/Internals.cpp
|
| diff --git a/third_party/WebKit/Source/core/testing/Internals.cpp b/third_party/WebKit/Source/core/testing/Internals.cpp
|
| index 0b5b0862d491c84491906679415eb55b37de11a9..3b798ec93b6e4f0519db810ffddef6c3e5ec2560 100644
|
| --- a/third_party/WebKit/Source/core/testing/Internals.cpp
|
| +++ b/third_party/WebKit/Source/core/testing/Internals.cpp
|
| @@ -157,6 +157,35 @@
|
|
|
| namespace blink {
|
|
|
| +namespace {
|
| +
|
| +class UseCounterObserverImpl final : public UseCounter::Observer {
|
| + WTF_MAKE_NONCOPYABLE(UseCounterObserverImpl);
|
| +
|
| + public:
|
| + UseCounterObserverImpl(ScriptPromiseResolver* resolver,
|
| + UseCounter::Feature feature)
|
| + : m_resolver(resolver), m_feature(feature) {}
|
| +
|
| + bool onCountFeature(UseCounter::Feature feature) final {
|
| + if (m_feature != feature)
|
| + return false;
|
| + m_resolver->resolve(feature);
|
| + return true;
|
| + }
|
| +
|
| + DEFINE_INLINE_VIRTUAL_TRACE() {
|
| + UseCounter::Observer::trace(visitor);
|
| + visitor->trace(m_resolver);
|
| + }
|
| +
|
| + private:
|
| + Member<ScriptPromiseResolver> m_resolver;
|
| + UseCounter::Feature m_feature;
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| static WTF::Optional<DocumentMarker::MarkerType> markerTypeFrom(
|
| const String& markerType) {
|
| if (equalIgnoringCase(markerType, "Spelling"))
|
| @@ -2986,6 +3015,34 @@ bool Internals::isCSSPropertyUseCounted(Document* document,
|
| return UseCounter::isCounted(*document, propertyName);
|
| }
|
|
|
| +ScriptPromise Internals::observeUseCounter(ScriptState* scriptState,
|
| + Document* document,
|
| + uint32_t feature) {
|
| + ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| + ScriptPromise promise = resolver->promise();
|
| + if (feature >= UseCounter::NumberOfFeatures) {
|
| + resolver->reject();
|
| + return promise;
|
| + }
|
| +
|
| + UseCounter::Feature useCounterFeature =
|
| + static_cast<UseCounter::Feature>(feature);
|
| + if (UseCounter::isCounted(*document, useCounterFeature)) {
|
| + resolver->resolve();
|
| + return promise;
|
| + }
|
| +
|
| + Frame* frame = document->frame();
|
| + if (!frame || !frame->host()) {
|
| + resolver->reject();
|
| + return promise;
|
| + }
|
| +
|
| + frame->host()->useCounter().addObserver(
|
| + new UseCounterObserverImpl(resolver, useCounterFeature));
|
| + return promise;
|
| +}
|
| +
|
| String Internals::unscopableAttribute() {
|
| return "unscopableAttribute";
|
| }
|
|
|