diff --git a/dom/media/test/crashtests/1127188.html b/dom/media/test/crashtests/1127188.html
new file mode 100644
index 000000000000..650f07dd4754
--- /dev/null
+++ b/dom/media/test/crashtests/1127188.html
@@ -0,0 +1,3 @@
+
diff --git a/dom/media/test/crashtests/crashtests.list b/dom/media/test/crashtests/crashtests.list
index e15df43c9efa..64ca51bc245b 100644
--- a/dom/media/test/crashtests/crashtests.list
+++ b/dom/media/test/crashtests/crashtests.list
@@ -78,6 +78,7 @@ load 1080986.html
load 1158427.html
load 1157994.html
load 1122218.html
+load 1127188.html
include ../../mediasource/test/crashtests/crashtests.list
# This needs to run at the end to avoid leaking busted state into other tests.
diff --git a/dom/media/webaudio/AudioContext.cpp b/dom/media/webaudio/AudioContext.cpp
index 22fb91750b59..278446491385 100644
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -769,13 +769,19 @@ private:
nsRefPtr mAudioContext;
};
-
-
void
AudioContext::OnStateChanged(void* aPromise, AudioContextState aNewState)
{
MOZ_ASSERT(NS_IsMainThread());
+ // This can happen if close() was called right after creating the
+ // AudioContext, before the context has switched to "running".
+ if (mAudioContextState == AudioContextState::Closed &&
+ aNewState == AudioContextState::Running &&
+ !aPromise) {
+ return;
+ }
+
MOZ_ASSERT((mAudioContextState == AudioContextState::Suspended &&
aNewState == AudioContextState::Running) ||
(mAudioContextState == AudioContextState::Running &&