diff options
Diffstat (limited to 'third_party')
5 files changed, 11 insertions, 15 deletions
diff --git a/third_party/WebKit/LayoutTests/webmidi/requestmidiaccess-in-detached-frame-expected.txt b/third_party/WebKit/LayoutTests/webmidi/requestmidiaccess-in-detached-frame-expected.txt index adcd69a..711be74 100644 --- a/third_party/WebKit/LayoutTests/webmidi/requestmidiaccess-in-detached-frame-expected.txt +++ b/third_party/WebKit/LayoutTests/webmidi/requestmidiaccess-in-detached-frame-expected.txt @@ -3,6 +3,8 @@ Tests navigator.requestMIDIAccess fails in a detached frame. On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". +PASS errorName is "AbortError" +PASS requestMIDIAccess() fail as expected. PASS successfullyParsed is true TEST COMPLETE diff --git a/third_party/WebKit/LayoutTests/webmidi/requestmidiaccess-in-detached-frame.html b/third_party/WebKit/LayoutTests/webmidi/requestmidiaccess-in-detached-frame.html index 47273b6..dbe30c2 100644 --- a/third_party/WebKit/LayoutTests/webmidi/requestmidiaccess-in-detached-frame.html +++ b/third_party/WebKit/LayoutTests/webmidi/requestmidiaccess-in-detached-frame.html @@ -13,19 +13,16 @@ document.body.appendChild(iframe); contentNavigator = iframe.contentWindow.navigator; document.body.removeChild(iframe); -// set testRunner configuration so that requestMIDIAccess returns "InvalidStateError". +// set testRunner configuration so that requestMIDIAccess returns "AbortError". contentNavigator.requestMIDIAccess().then(function() { testFailed("requestMIDIAccess() does not fail unexpectedly."); finishJSTest(); -}, function() { - errorName = error.name; - shouldBe("errorName", "'InvalidStateError'"); +}, function(error) { + window.errorName = error.name; + shouldBeEqualToString("errorName", 'AbortError'); testPassed("requestMIDIAccess() fail as expected."); finishJSTest(); }); -// FIXME: errorCallback should be called, but due to the Blink Promise impelementation the -// returned Promise never be resolved nor rejected. -finishJSTest(); </script> </body> diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp index 2e2f7be..2f11b0d 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp @@ -20,8 +20,10 @@ ScriptPromiseResolver::ScriptPromiseResolver(ScriptState* scriptState) , m_isPromiseCalled(false) #endif { - if (executionContext()->activeDOMObjectsAreStopped()) + if (executionContext()->activeDOMObjectsAreStopped()) { m_state = ResolvedOrRejected; + m_resolver.clear(); + } } void ScriptPromiseResolver::suspend() diff --git a/third_party/WebKit/Source/modules/battery/BatteryManager.cpp b/third_party/WebKit/Source/modules/battery/BatteryManager.cpp index 57cfa22..a100fe5 100644 --- a/third_party/WebKit/Source/modules/battery/BatteryManager.cpp +++ b/third_party/WebKit/Source/modules/battery/BatteryManager.cpp @@ -44,7 +44,6 @@ ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) if (m_state == Resolved) { // FIXME: Consider returning the same promise in this case. See crbug.com/385025. m_resolver->resolve(this); - m_resolver = nullptr; } else if (m_state == NotStarted) { m_state = Pending; m_hasEventListener = true; @@ -86,7 +85,6 @@ void BatteryManager::didUpdateData() ASSERT(m_resolver); m_state = Resolved; m_resolver->resolve(this); - m_resolver = nullptr; return; } diff --git a/third_party/WebKit/Source/modules/webmidi/NavigatorWebMIDI.cpp b/third_party/WebKit/Source/modules/webmidi/NavigatorWebMIDI.cpp index 4139e3b..9bff3d7 100644 --- a/third_party/WebKit/Source/modules/webmidi/NavigatorWebMIDI.cpp +++ b/third_party/WebKit/Source/modules/webmidi/NavigatorWebMIDI.cpp @@ -33,6 +33,7 @@ #include "bindings/core/v8/ScriptPromise.h" #include "bindings/core/v8/ScriptPromiseResolver.h" +#include "bindings/core/v8/V8DOMError.h" #include "core/dom/DOMError.h" #include "core/dom/Document.h" #include "core/frame/LocalFrame.h" @@ -78,11 +79,7 @@ ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, Navi ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, const MIDIOptions& options) { if (!frame() || frame()->document()->activeDOMObjectsAreStopped()) { - RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); - ScriptPromise promise = resolver->promise(); - // FIXME: Currently this rejection does not work because the context is stopped. - resolver->reject(DOMError::create("AbortError")); - return promise; + return ScriptPromise::reject(scriptState, toV8(DOMError::create("AbortError"), scriptState->context()->Global(), scriptState->isolate())); } return MIDIAccessInitializer::start(scriptState, options); |