diff --git a/content/html/content/src/HTMLMediaElement.cpp b/content/html/content/src/HTMLMediaElement.cpp
index 6aa73df091bf..75eca9fd6720 100644
--- a/content/html/content/src/HTMLMediaElement.cpp
+++ b/content/html/content/src/HTMLMediaElement.cpp
@@ -1137,14 +1137,14 @@ nsresult HTMLMediaElement::LoadResource()
ReportLoadError("MediaLoadInvalidURI", params, ArrayLength(params));
return rv;
}
- mMediaSource = source.forget();
nsRefPtr decoder = new MediaSourceDecoder(this);
- if (!mMediaSource->Attach(decoder)) {
+ if (!source->Attach(decoder)) {
// TODO: Handle failure: run "If the media data cannot be fetched at
// all, due to network errors, causing the user agent to give up
// trying to fetch the resource" section of resource fetch algorithm.
return NS_ERROR_FAILURE;
}
+ mMediaSource = source.forget();
nsRefPtr resource = new MediaSourceResource();
return FinishDecoderSetup(decoder, resource, nullptr, nullptr);
}
diff --git a/content/media/test/crashtests/926665.html b/content/media/test/crashtests/926665.html
new file mode 100644
index 000000000000..a8247b27e79e
--- /dev/null
+++ b/content/media/test/crashtests/926665.html
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
diff --git a/content/media/test/crashtests/crashtests.list b/content/media/test/crashtests/crashtests.list
index 4d1acbc64848..143e6588be17 100644
--- a/content/media/test/crashtests/crashtests.list
+++ b/content/media/test/crashtests/crashtests.list
@@ -59,3 +59,4 @@ load 910171-1.html
load 920987.html
skip-if(B2G) load oscillator-ended-1.html # intermittent B2G timeouts, bug 920338
skip-if(B2G) load oscillator-ended-2.html # intermittent B2G timeouts, bug 920338
+test-pref(media.mediasource.enabled,true) load 926665.html