Title: [270408] trunk
Revision
270408
Author
[email protected]
Date
2020-12-03 14:24:17 -0800 (Thu, 03 Dec 2020)

Log Message

Crash when trying to suspend an OfflineAudioContext with a bad buffer
https://bugs.webkit.org/show_bug.cgi?id=219496

Reviewed by Geoffrey Garen.

Source/WebCore:

Test: webaudio/OfflineAudioContext-bad-buffer-suspend-crash.html

* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
Throw a NotSupportedError for consistency with Blink.

(WebCore::OfflineAudioContext::suspendOfflineRendering):
Use length() instead of dereferencing the potentially null renderTarget to get
the length.

LayoutTests:

Add layout test coverage.

* webaudio/OfflineAudioContext-bad-buffer-suspend-crash-expected.txt: Added.
* webaudio/OfflineAudioContext-bad-buffer-suspend-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (270407 => 270408)


--- trunk/LayoutTests/ChangeLog	2020-12-03 21:14:56 UTC (rev 270407)
+++ trunk/LayoutTests/ChangeLog	2020-12-03 22:24:17 UTC (rev 270408)
@@ -1,3 +1,15 @@
+2020-12-03  Chris Dumez  <[email protected]>
+
+        Crash when trying to suspend an OfflineAudioContext with a bad buffer
+        https://bugs.webkit.org/show_bug.cgi?id=219496
+
+        Reviewed by Geoffrey Garen.
+
+        Add layout test coverage.
+
+        * webaudio/OfflineAudioContext-bad-buffer-suspend-crash-expected.txt: Added.
+        * webaudio/OfflineAudioContext-bad-buffer-suspend-crash.html: Added.
+
 2020-12-03  Aditya Keerthi  <[email protected]>
 
         [iOS][FCR] Add new look for search fields

Added: trunk/LayoutTests/webaudio/OfflineAudioContext-bad-buffer-suspend-crash-expected.txt (0 => 270408)


--- trunk/LayoutTests/webaudio/OfflineAudioContext-bad-buffer-suspend-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webaudio/OfflineAudioContext-bad-buffer-suspend-crash-expected.txt	2020-12-03 22:24:17 UTC (rev 270408)
@@ -0,0 +1,15 @@
+CONSOLE MESSAGE: Failed to construct internal AudioBuffer with 1 channel(s), a sample rate of 8000 and a length of 4294967295.
+Tests that we do not crash when trying to suspend an OfflineAudioContext with a bad buffer.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS context.sampleRate is 8000
+PASS context.length is 4294967295
+PASS context.state is "suspended"
+PASS startRendering() promise should get rejected. rejected promise  with NotSupportedError: Failed to create audio buffer.
+PASS context.state is "suspended"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/webaudio/OfflineAudioContext-bad-buffer-suspend-crash.html (0 => 270408)


--- trunk/LayoutTests/webaudio/OfflineAudioContext-bad-buffer-suspend-crash.html	                        (rev 0)
+++ trunk/LayoutTests/webaudio/OfflineAudioContext-bad-buffer-suspend-crash.html	2020-12-03 22:24:17 UTC (rev 270408)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+    description("Tests that we do not crash when trying to suspend an OfflineAudioContext with a bad buffer.");
+    jsTestIsAsync = true;
+
+    async function test() {
+        context = new OfflineAudioContext({ length: -1, sampleRate: 8000 });
+        context.suspend(0);
+        shouldBe("context.sampleRate", "8000");
+        shouldBe("context.length", "4294967295");
+        shouldBeEqualToString("context.state", "suspended");
+        await shouldRejectWithErrorName("context.startRendering()", "NotSupportedError", "startRendering() promise should get rejected.");
+        shouldBeEqualToString("context.state", "suspended");
+        finishJSTest();
+    }
+
+    _onload_ = test;
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/webaudio/dom-exceptions-expected.txt (270407 => 270408)


--- trunk/LayoutTests/webaudio/dom-exceptions-expected.txt	2020-12-03 21:14:56 UTC (rev 270407)
+++ trunk/LayoutTests/webaudio/dom-exceptions-expected.txt	2020-12-03 22:24:17 UTC (rev 270408)
@@ -152,7 +152,7 @@
 PASS < [invalid-offline-audio-context-parameters] All assertions passed. (total 5 assertions)
 PASS > [invalid-frame-length]
 PASS   testContext = new OfflineAudioContext(1, -88200000000000, 44100) did not throw an exception.
-PASS   testContext.startRendering() rejected correctly with InvalidStateError: Failed to create audio buffer.
+PASS   testContext.startRendering() rejected correctly with NotSupportedError: Failed to create audio buffer.
 PASS < [invalid-frame-length] All assertions passed. (total 2 assertions)
 PASS > [waveshaper]
 PASS   node.oversample = "9x" did not throw an exception.

Modified: trunk/Source/WebCore/ChangeLog (270407 => 270408)


--- trunk/Source/WebCore/ChangeLog	2020-12-03 21:14:56 UTC (rev 270407)
+++ trunk/Source/WebCore/ChangeLog	2020-12-03 22:24:17 UTC (rev 270408)
@@ -1,5 +1,22 @@
 2020-12-03  Chris Dumez  <[email protected]>
 
+        Crash when trying to suspend an OfflineAudioContext with a bad buffer
+        https://bugs.webkit.org/show_bug.cgi?id=219496
+
+        Reviewed by Geoffrey Garen.
+
+        Test: webaudio/OfflineAudioContext-bad-buffer-suspend-crash.html
+
+        * Modules/webaudio/OfflineAudioContext.cpp:
+        (WebCore::OfflineAudioContext::startOfflineRendering):
+        Throw a NotSupportedError for consistency with Blink.
+
+        (WebCore::OfflineAudioContext::suspendOfflineRendering):
+        Use length() instead of dereferencing the potentially null renderTarget to get
+        the length.
+
+2020-12-03  Chris Dumez  <[email protected]>
+
         Refactor macros for low power mode code
         https://bugs.webkit.org/show_bug.cgi?id=219497
 

Modified: trunk/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp (270407 => 270408)


--- trunk/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp	2020-12-03 21:14:56 UTC (rev 270407)
+++ trunk/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp	2020-12-03 22:24:17 UTC (rev 270408)
@@ -103,7 +103,7 @@
     }
 
     if (!renderTarget()) {
-        promise->reject(Exception { InvalidStateError, "Failed to create audio buffer"_s });
+        promise->reject(Exception { NotSupportedError, "Failed to create audio buffer"_s });
         return;
     }
 
@@ -134,7 +134,7 @@
         return;
     }
 
-    double totalRenderDuration = renderTarget()->length() / sampleRate();
+    double totalRenderDuration = length() / sampleRate();
     if (totalRenderDuration <= suspendTime) {
         promise->reject(Exception { InvalidStateError, "suspendTime cannot be greater than total rendering duration"_s });
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to