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

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

Issue 2666703002: Correct confusing error message from OfflineAudioContext.suspend() (Closed)
Patch Set: Refined error message 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..39e70ed8a4ae3b1ce5ba53d9442f7db01fd3374e 100644
--- a/third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp
@@ -257,13 +257,15 @@ 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)"));
+ "suspend(" + String::number(when) + ") failed to suspend at frame " +
+ String::number(frame) + " because it is earlier than the current " +
+ "frame of " + String::number(currentFrameClamped) + " (" +
+ String::number(currentTimeClamped) + " seconds)"));
return promise;
}

Powered by Google App Engine
This is Rietveld 408576698