Title: [265681] trunk
- Revision
- 265681
- Author
- [email protected]
- Date
- 2020-08-14 11:19:42 -0700 (Fri, 14 Aug 2020)
Log Message
AudioBufferSourceNode.buffer setter should throw when the buffer was already set
https://bugs.webkit.org/show_bug.cgi?id=215510
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Rebaseline WPT test now that all checks are passing.
* web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels-expected.txt:
Source/WebCore:
AudioBufferSourceNode.buffer setter should throw when the buffer was already set:
- https://www.w3.org/TR/webaudio/#dom-audiobuffersourcenode-buffer
Note that the setter for the WebKit-prefixed AudioBufferSourceNode still does not throw,
to ensure backward-compatibility.
No new tests, rebaselined existing test.
* Modules/webaudio/AudioBufferSourceNode.cpp:
(WebCore::AudioBufferSourceNode::setBuffer):
* Modules/webaudio/AudioBufferSourceNode.h:
(WebCore::AudioBufferSourceNode::isWebKitAudioBufferSourceNode const):
* Modules/webaudio/WebKitAudioBufferSourceNode.h:
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (265680 => 265681)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2020-08-14 17:54:30 UTC (rev 265680)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2020-08-14 18:19:42 UTC (rev 265681)
@@ -1,3 +1,14 @@
+2020-08-14 Chris Dumez <[email protected]>
+
+ AudioBufferSourceNode.buffer setter should throw when the buffer was already set
+ https://bugs.webkit.org/show_bug.cgi?id=215510
+
+ Reviewed by Darin Adler.
+
+ Rebaseline WPT test now that all checks are passing.
+
+ * web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels-expected.txt:
+
2020-08-14 Takeshi Kurosawa <[email protected]>
@font-face font-weight descriptor should reject bolder and lighter
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels-expected.txt (265680 => 265681)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels-expected.txt 2020-08-14 17:54:30 UTC (rev 265680)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels-expected.txt 2020-08-14 18:19:42 UTC (rev 265681)
@@ -6,9 +6,9 @@
PASS source.buffer = 57 threw TypeError: "The AudioBufferSourceNode.buffer attribute must be an instance of AudioBuffer".
PASS source.buffer = null did not throw an exception.
PASS source.buffer = buffer did not throw an exception.
-FAIL X source.buffer = new buffer did not throw an exception. assert_true: expected true got false
+PASS source.buffer = new buffer threw InvalidStateError: "The buffer was already set".
PASS source.buffer = null again did not throw an exception.
-FAIL X source.buffer = buffer again did not throw an exception. assert_true: expected true got false
+PASS source.buffer = buffer again threw InvalidStateError: "The buffer was already set".
PASS source.buffer = null after setting to null did not throw an exception.
PASS Setting source with mono buffer did not throw an exception.
PASS Setting source with stereo buffer did not throw an exception.
@@ -19,6 +19,6 @@
PASS Setting source with 7 channels buffer did not throw an exception.
PASS Setting source with 8 channels buffer did not throw an exception.
PASS Setting source with 9 channels buffer did not throw an exception.
-FAIL < [validate .buffer] 2 out of 16 assertions were failed. assert_true: expected true got false
-FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed. assert_true: expected true got false
+PASS < [validate .buffer] All assertions passed. (total 16 assertions)
+PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully.
Modified: trunk/Source/WebCore/ChangeLog (265680 => 265681)
--- trunk/Source/WebCore/ChangeLog 2020-08-14 17:54:30 UTC (rev 265680)
+++ trunk/Source/WebCore/ChangeLog 2020-08-14 18:19:42 UTC (rev 265681)
@@ -1,3 +1,24 @@
+2020-08-14 Chris Dumez <[email protected]>
+
+ AudioBufferSourceNode.buffer setter should throw when the buffer was already set
+ https://bugs.webkit.org/show_bug.cgi?id=215510
+
+ Reviewed by Darin Adler.
+
+ AudioBufferSourceNode.buffer setter should throw when the buffer was already set:
+ - https://www.w3.org/TR/webaudio/#dom-audiobuffersourcenode-buffer
+
+ Note that the setter for the WebKit-prefixed AudioBufferSourceNode still does not throw,
+ to ensure backward-compatibility.
+
+ No new tests, rebaselined existing test.
+
+ * Modules/webaudio/AudioBufferSourceNode.cpp:
+ (WebCore::AudioBufferSourceNode::setBuffer):
+ * Modules/webaudio/AudioBufferSourceNode.h:
+ (WebCore::AudioBufferSourceNode::isWebKitAudioBufferSourceNode const):
+ * Modules/webaudio/WebKitAudioBufferSourceNode.h:
+
2020-08-14 Wenson Hsieh <[email protected]>
REGRESSION (r259184): Typing -- then Return into an email moves the selection by two lines
Modified: trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp (265680 => 265681)
--- trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp 2020-08-14 17:54:30 UTC (rev 265680)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp 2020-08-14 18:19:42 UTC (rev 265681)
@@ -418,11 +418,14 @@
m_lastGain = legacyGainValue();
}
-void AudioBufferSourceNode::setBuffer(RefPtr<AudioBuffer>&& buffer)
+ExceptionOr<void> AudioBufferSourceNode::setBuffer(RefPtr<AudioBuffer>&& buffer)
{
ASSERT(isMainThread());
DEBUG_LOG(LOGIDENTIFIER);
+ if (buffer && m_wasBufferSet && shouldThrowOnAttemptToOverwriteBuffer())
+ return Exception { InvalidStateError, "The buffer was already set"_s };
+
// The context must be locked since changing the buffer can re-configure the number of channels that are output.
BaseAudioContext::AutoLocker contextLocker(context());
@@ -430,6 +433,8 @@
auto locker = holdLock(m_processMutex);
if (buffer) {
+ m_wasBufferSet = true;
+
// Do any necesssary re-configuration to the buffer's number of channels.
unsigned numberOfChannels = buffer->numberOfChannels();
ASSERT(numberOfChannels <= AudioContext::maxNumberOfChannels());
@@ -445,6 +450,7 @@
m_virtualReadIndex = 0;
m_buffer = WTFMove(buffer);
+ return { };
}
unsigned AudioBufferSourceNode::numberOfChannels()
Modified: trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h (265680 => 265681)
--- trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h 2020-08-14 17:54:30 UTC (rev 265680)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h 2020-08-14 18:19:42 UTC (rev 265681)
@@ -52,8 +52,7 @@
void reset() final;
// setBuffer() is called on the main thread. This is the buffer we use for playback.
- // returns true on success.
- void setBuffer(RefPtr<AudioBuffer>&&);
+ ExceptionOr<void> setBuffer(RefPtr<AudioBuffer>&&);
AudioBuffer* buffer() { return m_buffer.get(); }
// numberOfChannels() returns the number of output channels. This value equals the number of channels from the buffer.
@@ -98,6 +97,7 @@
double latencyTime() const final { return 0; }
virtual double legacyGainValue() const { return 1.0; }
+ virtual bool shouldThrowOnAttemptToOverwriteBuffer() const { return true; }
enum BufferPlaybackMode {
Entire,
@@ -126,6 +126,8 @@
// If true, it will wrap around to the start of the buffer each time it reaches the end.
bool m_isLooping { false };
+ bool m_wasBufferSet { false };
+
double m_loopStart { 0 };
double m_loopEnd { 0 };
Modified: trunk/Source/WebCore/Modules/webaudio/WebKitAudioBufferSourceNode.h (265680 => 265681)
--- trunk/Source/WebCore/Modules/webaudio/WebKitAudioBufferSourceNode.h 2020-08-14 17:54:30 UTC (rev 265680)
+++ trunk/Source/WebCore/Modules/webaudio/WebKitAudioBufferSourceNode.h 2020-08-14 18:19:42 UTC (rev 265681)
@@ -47,6 +47,7 @@
{
}
+ bool shouldThrowOnAttemptToOverwriteBuffer() const final { return false; }
double legacyGainValue() const final { return gain().value(); }
Ref<AudioParam> m_gain;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes