Bug 752087: Use correct method to check is a jsval is an object r=roc
authorRandell Jesup <rjesup@jesup.org>
Mon, 07 May 2012 18:54:29 -0400
changeset 93422 c77b4c6085c1411135e42b6ba6bd0d40490a75a9
parent 93421 764c37699d2af6b56bbdb8db6fd4f1a0a99eaa30
child 93423 746e2b96552110c4112a13f0afa645881b03116e
push id22634
push useremorley@mozilla.com
push dateTue, 08 May 2012 09:48:43 +0000
treeherdermozilla-central@e4f9e2eab6b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs752087
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 752087: Use correct method to check is a jsval is an object r=roc
content/html/content/src/nsHTMLMediaElement.cpp
content/media/test/Makefile.in
content/media/test/test_source_null.html
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -474,17 +474,17 @@ nsHTMLMediaElement::GetSrc(JSContext* aC
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLMediaElement::SetSrc(JSContext* aCtx, const jsval & aParams)
 {
-  if (JSVAL_IS_OBJECT(aParams)) {
+  if (aParams.isObject()) { // not JSVAL_IS_OBJECT() because a null object is still an object
     nsCOMPtr<nsIDOMMediaStream> stream;
     stream = do_QueryInterface(nsContentUtils::XPConnect()->
         GetNativeOfWrapper(aCtx, JSVAL_TO_OBJECT(aParams)));
     if (stream) {
       mSrcAttrStream = static_cast<nsDOMMediaStream*>(stream.get());
       UnsetAttr(kNameSpaceID_None, nsGkAtoms::src, true);
       Load();
       return NS_OK;
--- a/content/media/test/Makefile.in
+++ b/content/media/test/Makefile.in
@@ -132,29 +132,30 @@ include $(topsrcdir)/config/rules.mk
 		test_new_audio.html \
 		test_paused.html \
 		test_paused_after_ended.html \
 		test_play_events.html \
 		test_play_events_2.html \
 		test_played.html \
 		test_playback.html \
 		test_playback_errors.html \
- 		test_seekable1.html \
+		test_seekable1.html \
 		test_preload_actions.html \
 		test_preload_attribute.html \
 		test_progress.html \
 		test_reactivate.html \
 		test_readyState.html \
 		test_replay_metadata.html \
 		test_seek.html \
 		test_seek2.html \
 		test_seekLies.html \
 		test_seek_out_of_range.html \
 		test_source.html \
 		test_source_write.html \
+	        test_source_null.html \
 		test_standalone.html \
 		test_streams_element_capture.html \
 		test_streams_element_capture_reset.html \
 		test_timeupdate_small_files.html \
 		test_too_many_elements.html \
 		test_volume.html \
 		test_video_to_canvas.html \
 		use_large_cache.js \
new file mode 100644
--- /dev/null
+++ b/content/media/test/test_source_null.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=752087
+-->
+<head>
+  <title>Test for Bug 752087</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="text/javascript" src="manifest.js"></script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=752087">Mozilla Bug 752087</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+
+<video id="v">
+<script>
+var v = document.getElementById('v');
+v.src = null; // crashes on NULL access if not handled
+
+ok(true, "setting video.src to null didn't crash!");
+</script>
+</video>
+</body>
+</html>