Changeset 268999 in webkit


Ignore:
Timestamp:
Oct 26, 2020 4:09:16 PM (21 months ago)
Author:
Chris Dumez
Message:

Improve exception messages when AudioContext.suspend() / resume() promises are rejected
https://bugs.webkit.org/show_bug.cgi?id=218210

Reviewed by Geoffrey Garen.

Source/WebCore:

Improve exception messages when AudioContext.suspend() / resume() promises are rejected.

No new tests, rebaselined existing tests.

  • Modules/webaudio/AudioContext.cpp:

(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):

LayoutTests:

  • webaudio/audiocontext-state.html:

Stop expecting that the resume() promise is rejected without any exception.
This is not standard behavior and does not match the behavior of other
browsers either.

  • webaudio/construct-node-with-closed-context-expected.txt:

Rebaseline test now that exception messages have been improved.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r268997 r268999  
     12020-10-26  Chris Dumez  <cdumez@apple.com>
     2
     3        Improve exception messages when AudioContext.suspend() / resume() promises are rejected
     4        https://bugs.webkit.org/show_bug.cgi?id=218210
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * webaudio/audiocontext-state.html:
     9        Stop expecting that the resume() promise is rejected without any exception.
     10        This is not standard behavior and does not match the behavior of other
     11        browsers either.
     12
     13        * webaudio/construct-node-with-closed-context-expected.txt:
     14        Rebaseline test now that exception messages have been improved.
     15
    1162020-10-26  Truitt Savell  <tsavell@apple.com>
    217
  • trunk/LayoutTests/webaudio/audiocontext-state.html

    r267504 r268999  
    9494function resumeFailedCorrectly(value) {
    9595    testPassed('context.resume() promise rejected (correctly)');
    96     if (typeof value != 'undefined')
    97         testFailed('No value should be passed to the context.resume() promise rejected callback');
    9896    shouldBe('context.state', '"closed"');
    9997
  • trunk/LayoutTests/webaudio/construct-node-with-closed-context-expected.txt

    r267639 r268999  
    4141PASS context.createWaveShaper() did not throw exception.
    4242PASS context.createScriptProcessor() did not throw exception.
    43 PASS context.suspend() rejected promise  with InvalidStateError: The object is in an invalid state..
    44 PASS context.resume() rejected promise  with InvalidStateError: The object is in an invalid state..
     43PASS context.suspend() rejected promise  with InvalidStateError: Context is closed.
     44PASS context.resume() rejected promise  with InvalidStateError: Context is closed.
    4545PASS context.close() rejected promise  with InvalidStateError: The object is in an invalid state..
    4646PASS successfullyParsed is true
  • trunk/Source/WebCore/ChangeLog

    r268998 r268999  
     12020-10-26  Chris Dumez  <cdumez@apple.com>
     2
     3        Improve exception messages when AudioContext.suspend() / resume() promises are rejected
     4        https://bugs.webkit.org/show_bug.cgi?id=218210
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Improve exception messages when AudioContext.suspend() / resume() promises are rejected.
     9
     10        No new tests, rebaselined existing tests.
     11
     12        * Modules/webaudio/AudioContext.cpp:
     13        (WebCore::AudioContext::suspendRendering):
     14        (WebCore::AudioContext::resumeRendering):
     15
    1162020-10-26  Adrian Perez de Castro  <aperez@igalia.com>
    217
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp

    r268893 r268999  
    205205void AudioContext::suspendRendering(DOMPromiseDeferred<void>&& promise)
    206206{
    207     if (isOfflineContext() || isStopped()) {
    208         promise.reject(InvalidStateError);
    209         return;
    210     }
    211 
    212     if (state() == State::Closed || state() == State::Interrupted || !destinationNode()) {
    213         promise.reject();
     207    if (isOfflineContext()) {
     208        promise.reject(Exception { InvalidStateError, "Cannot call suspend() on an OfflineAudioContext"_s });
     209        return;
     210    }
     211
     212    if (isStopped() || state() == State::Closed || state() == State::Interrupted || !destinationNode()) {
     213        promise.reject(Exception { InvalidStateError, "Context is closed"_s });
    214214        return;
    215215    }
     
    230230void AudioContext::resumeRendering(DOMPromiseDeferred<void>&& promise)
    231231{
    232     if (isOfflineContext() || isStopped()) {
    233         promise.reject(InvalidStateError);
    234         return;
    235     }
    236 
    237     if (state() == State::Closed || !destinationNode()) {
    238         promise.reject();
     232    if (isOfflineContext()) {
     233        promise.reject(Exception { InvalidStateError, "Cannot call resume() on an OfflineAudioContext"_s });
     234        return;
     235    }
     236
     237    if (isStopped() || state() == State::Closed || !destinationNode()) {
     238        promise.reject(Exception { InvalidStateError, "Context is closed"_s });
    239239        return;
    240240    }
Note: See TracChangeset for help on using the changeset viewer.