Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Unified Diff: third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp

Issue 2666703002: Correct confusing error message from OfflineAudioContext.suspend() (Closed)
Patch Set: Added layout test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp b/third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp
index b841030a4a2a57ba255de22b39391b3c5e97f2aa..9f092967306e006c36927bec07e741521b2e87e3 100644
--- a/third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp
@@ -257,13 +257,16 @@ ScriptPromise OfflineAudioContext::suspendContext(ScriptState* scriptState,
// The specified suspend time is in the past; reject the promise.
if (frame < currentSampleFrame()) {
+ size_t currentFrameClamped = std::min(currentSampleFrame(), length());
+ double currentTimeClamped =
+ std::min(currentTime(), length() / static_cast<double>(sampleRate()));
resolver->reject(DOMException::create(
InvalidStateError,
"cannot schedule a suspend at frame " + String::number(frame) + " (" +
String::number(when) +
" seconds) because it is earlier than the current frame of " +
- String::number(currentSampleFrame()) + " (" +
- String::number(currentTime()) + " seconds)"));
+ String::number(currentFrameClamped) + " (" +
+ String::number(currentTimeClamped) + " seconds)"));
return promise;
}

Powered by Google App Engine
This is Rietveld 408576698