Bug 1079844 - Change various non-js/ files/tests/etc. to refer to detaching of ArrayBuffers rather than neutering. (DOM references to "neutering" of DOM things remain as neutering.) r=bz
authorJeff Walden <jwalden@mit.edu>
Mon, 25 Jan 2016 18:10:22 -0800
changeset 282169 b9fb3bb07c79b86bf59b165efea3286422df1734
parent 282168 fb168daab73e9b45369803e28eb644e92ac77ad1
child 282170 1979d17880e6c674e88ba4235308ad449affce6f
push id19510
push usergwagner@mozilla.com
push dateMon, 08 Feb 2016 15:56:48 +0000
treeherderb2g-inbound@a3d54e32dee1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1079844
milestone47.0a1
Bug 1079844 - Change various non-js/ files/tests/etc. to refer to detaching of ArrayBuffers rather than neutering. (DOM references to "neutering" of DOM things remain as neutering.) r=bz
dom/canvas/test/test_imagebitmap_on_worker.html
dom/media/webaudio/AudioBuffer.cpp
dom/media/webaudio/AudioBuffer.h
dom/media/webaudio/AudioContext.cpp
dom/media/webaudio/test/audioBufferSourceNodeDetached_worker.js
dom/media/webaudio/test/audioBufferSourceNodeNeutered_worker.js
dom/media/webaudio/test/mochitest.ini
dom/media/webaudio/test/test_AudioBuffer.html
dom/media/webaudio/test/test_audioBufferSourceNodeDetached.html
dom/media/webaudio/test/test_audioBufferSourceNodeNeutered.html
dom/media/webaudio/test/test_mediaDecoding.html
dom/tests/mochitest/whatwg/test_postMessage_transfer.html
netwerk/test/mochitests/test_arraybufferinputstream.html
toolkit/components/promiseworker/tests/xpcshell/test_Promise.js
toolkit/components/thumbnails/PageThumbs.jsm
--- a/dom/canvas/test/test_imagebitmap_on_worker.html
+++ b/dom/canvas/test/test_imagebitmap_on_worker.html
@@ -90,17 +90,17 @@ function runTests() {
   };
 
   // task: throw exception: general: sw == 0 || sh == 0
   WORKER_TASKS.tasks.push(new TaskWithCrop("testException", 0, 0, "createImageBitmap should throw with 0 width/height", imageData, 0, 0, 0, 0));
 
   // task: throw exception: general: source is a null
   WORKER_TASKS.tasks.push(new TaskWithCrop("testException", 0, 0, "createImageBitmap should throw with null source", null, 0, 0, 0, 0));
 
-  // task: throw exception: ImageData: an ImageData object whose data is data attribute has been neutered
+  // task: throw exception: ImageData: an ImageData object whose data attribute is backed by a detached buffer
   var neuturedImageData = function getNeuturedImageData(imageData) {
   	worker.postMessage(imageData.data.buffer, [imageData.data.buffer]);
   	return imageData;
   }(ctx.getImageData(0, 0, 50, 50));
   WORKER_TASKS.tasks.push(new TaskWithCrop("testException", neuturedImageData.width, neuturedImageData.height,
                                            "createImageBitmap should throw with neutured ImageData",
                                            neuturedImageData, 0, 0, neuturedImageData.width, neuturedImageData.height));
 
--- a/dom/media/webaudio/AudioBuffer.cpp
+++ b/dom/media/webaudio/AudioBuffer.cpp
@@ -146,17 +146,17 @@ AudioBuffer::CopyFromChannel(const Float
     return;
   }
 
   JS::AutoCheckCannotGC nogc;
   JSObject* channelArray = mJSChannels[aChannelNumber];
   const float* sourceData = nullptr;
   if (channelArray) {
     if (JS_GetTypedArrayLength(channelArray) != mLength) {
-      // The array was probably neutered
+      // The array's buffer was detached.
       aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
       return;
     }
 
     bool isShared = false;
     sourceData = JS_GetFloat32ArrayData(channelArray, &isShared, nogc);
     // The sourceData arrays should all have originated in
     // RestoreJSChannelData, where they are created unshared.
@@ -191,17 +191,17 @@ AudioBuffer::CopyToChannel(JSContext* aJ
   if (!RestoreJSChannelData(aJSContext)) {
     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
   JS::AutoCheckCannotGC nogc;
   JSObject* channelArray = mJSChannels[aChannelNumber];
   if (JS_GetTypedArrayLength(channelArray) != mLength) {
-    // The array was probably neutered
+    // The array's buffer was detached.
     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return;
   }
 
   bool isShared = false;
   float* channelData = JS_GetFloat32ArrayData(channelArray, &isShared, nogc);
   // The channelData arrays should all have originated in
   // RestoreJSChannelData, where they are created unshared.
@@ -228,28 +228,28 @@ AudioBuffer::GetChannelData(JSContext* a
     JS::ExposeObjectToActiveJS(mJSChannels[aChannel]);
   }
   aRetval.set(mJSChannels[aChannel]);
 }
 
 already_AddRefed<ThreadSharedFloatArrayBufferList>
 AudioBuffer::StealJSArrayDataIntoSharedChannels(JSContext* aJSContext)
 {
-  // "1. If any of the AudioBuffer's ArrayBuffer have been neutered, abort
+  // "1. If any of the AudioBuffer's ArrayBuffer have been detached, abort
   // these steps, and return a zero-length channel data buffers to the
   // invoker."
   for (uint32_t i = 0; i < mJSChannels.Length(); ++i) {
     JSObject* channelArray = mJSChannels[i];
     if (!channelArray || mLength != JS_GetTypedArrayLength(channelArray)) {
-      // Either empty buffer or one of the arrays was probably neutered
+      // Either empty buffer or one of the arrays' buffers was detached.
       return nullptr;
     }
   }
 
-  // "2. Neuter all ArrayBuffers for arrays previously returned by
+  // "2. Detach all ArrayBuffers for arrays previously returned by
   // getChannelData on this AudioBuffer."
   // "3. Retain the underlying data buffers from those ArrayBuffers and return
   // references to them to the invoker."
   RefPtr<ThreadSharedFloatArrayBufferList> result =
     new ThreadSharedFloatArrayBufferList(mJSChannels.Length());
   for (uint32_t i = 0; i < mJSChannels.Length(); ++i) {
     JS::Rooted<JSObject*> arrayBufferView(aJSContext, mJSChannels[i]);
     bool isSharedMemory;
--- a/dom/media/webaudio/AudioBuffer.h
+++ b/dom/media/webaudio/AudioBuffer.h
@@ -22,18 +22,18 @@ class ErrorResult;
 class ThreadSharedFloatArrayBufferList;
 
 namespace dom {
 
 class AudioContext;
 
 /**
  * An AudioBuffer keeps its data either in the mJSChannels objects, which
- * are Float32Arrays, or in mSharedChannels if the mJSChannels objects have
- * been neutered.
+ * are Float32Arrays, or in mSharedChannels if the mJSChannels objects' buffers
+ * are detached.
  */
 class AudioBuffer final : public nsWrapperCache
 {
 public:
   // If non-null, aInitialContents must have number of channels equal to
   // aNumberOfChannels and their lengths must be at least aLength.
   static already_AddRefed<AudioBuffer>
   Create(AudioContext* aContext, uint32_t aNumberOfChannels,
@@ -117,17 +117,17 @@ protected:
 
   void ClearJSChannels();
 
   nsWeakPtr mOwnerWindow;
   // Float32Arrays
   nsAutoTArray<JS::Heap<JSObject*>, 2> mJSChannels;
 
   // mSharedChannels aggregates the data from mJSChannels. This is non-null
-  // if and only if the mJSChannels are neutered.
+  // if and only if the mJSChannels' buffers are detached.
   RefPtr<ThreadSharedFloatArrayBufferList> mSharedChannels;
 
   uint32_t mLength;
   float mSampleRate;
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -570,17 +570,17 @@ AudioContext::DecodeAudioData(const Arra
   aBuffer.ComputeLengthAndData();
 
   if (aBuffer.IsShared()) {
     // Throw if the object is mapping shared memory (must opt in).
     aRv.ThrowTypeError<MSG_TYPEDARRAY_IS_SHARED>(NS_LITERAL_STRING("Argument of AudioContext.decodeAudioData"));
     return nullptr;
   }
 
-  // Neuter the array buffer
+  // Detach the array buffer
   size_t length = aBuffer.Length();
   JS::RootedObject obj(cx, aBuffer.Obj());
 
   uint8_t* data = static_cast<uint8_t*>(JS_StealArrayBufferContents(cx, obj));
 
   // Sniff the content of the media.
   // Failed type sniffing will be handled by AsyncDecodeWebAudio.
   nsAutoCString contentType;
rename from dom/media/webaudio/test/audioBufferSourceNodeNeutered_worker.js
rename to dom/media/webaudio/test/audioBufferSourceNodeDetached_worker.js
--- a/dom/media/webaudio/test/mochitest.ini
+++ b/dom/media/webaudio/test/mochitest.ini
@@ -3,17 +3,17 @@ tags=msg
 tags = webaudio
 skip-if = ((buildapp == 'b2g') && (toolkit != 'gonk' || debug)) || (os == 'win' && strictContentSandbox) #b2g-debug,b2g-desktop(bug 916135); strictContentSandbox(Bug 1042735)
 support-files =
   audio-expected.wav
   audio-mono-expected-2.wav
   audio-mono-expected.wav
   audio-quad.wav
   audio.ogv
-  audioBufferSourceNodeNeutered_worker.js
+  audioBufferSourceNodeDetached_worker.js
   corsServer.sjs
   invalid.txt
   layouttest-glue.js
   noaudio.webm
   small-shot-expected.wav
   small-shot-mono-expected.wav
   small-shot.ogg
   small-shot.mp3
@@ -34,17 +34,17 @@ support-files =
 [test_analyserNodeWithGain.html]
 [test_AudioBuffer.html]
 [test_audioBufferSourceNode.html]
 [test_audioBufferSourceNodeEnded.html]
 [test_audioBufferSourceNodeLazyLoopParam.html]
 [test_audioBufferSourceNodeLoop.html]
 [test_audioBufferSourceNodeLoopStartEnd.html]
 [test_audioBufferSourceNodeLoopStartEndSame.html]
-[test_audioBufferSourceNodeNeutered.html]
+[test_audioBufferSourceNodeDetached.html]
 skip-if = (toolkit == 'android' && (processor == 'x86' || debug)) || os == 'win' # bug 1127845, bug 1138468
 [test_audioBufferSourceNodeNoStart.html]
 [test_audioBufferSourceNodeNullBuffer.html]
 [test_audioBufferSourceNodeOffset.html]
 skip-if = (toolkit == 'gonk') || (toolkit == 'android') || debug #bug 906752
 [test_audioBufferSourceNodePassThrough.html]
 [test_audioBufferSourceNodeRate.html]
 [test_AudioContext.html]
--- a/dom/media/webaudio/test/test_AudioBuffer.html
+++ b/dom/media/webaudio/test/test_AudioBuffer.html
@@ -60,18 +60,18 @@ addLoadEvent(function() {
   for (var i = 0; i < changedData.length; ++i) {
     if (i < 100 || i >= 300) {
       is(changedData[i], i, "Untouched sample");
     } else {
       is(changedData[i], 0, "Correct sample");
     }
   }
 
-  // Now, neuter the array buffer
-  var worker = new Worker("audioBufferSourceNodeNeutered_worker.js");
+  // Now, detach the array buffer
+  var worker = new Worker("audioBufferSourceNodeDetached_worker.js");
   var data = buffer.getChannelData(0).buffer;
   worker.postMessage(data, [data]);
   SpecialPowers.gc();
 
   expectException(function() {
     buffer.copyFromChannel(copy, 0, 1024);
   }, DOMException.INDEX_SIZE_ERR);
 
rename from dom/media/webaudio/test/test_audioBufferSourceNodeNeutered.html
rename to dom/media/webaudio/test/test_audioBufferSourceNodeDetached.html
--- a/dom/media/webaudio/test/test_audioBufferSourceNodeNeutered.html
+++ b/dom/media/webaudio/test/test_audioBufferSourceNodeDetached.html
@@ -1,12 +1,12 @@
 <!DOCTYPE HTML>
 <html>
 <head>
-  <title>Test AudioBufferSourceNode when an AudioBuffer's getChanneData array is neutered</title>
+  <title>Test AudioBufferSourceNode when an AudioBuffer's getChanneData buffer is detached</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="webaudio.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
@@ -17,29 +17,29 @@ function createGarbage() {
   }
   var sum = 0;
   for (var i = 0; i < s.length; ++i) {
     sum += s[i];
   }
   return sum;
 }
 
-var worker = new Worker("audioBufferSourceNodeNeutered_worker.js");
+var worker = new Worker("audioBufferSourceNodeDetached_worker.js");
 
 var gTest = {
   length: 2048,
   numberOfChannels: 1,
   createGraph: function(context) {
     var buffer = context.createBuffer(1, 10000000, context.sampleRate);
     var data = buffer.getChannelData(0);
     for (var i = 0; i < data.length; ++i) {
       data[i] = (i%100)/100 - 0.5;
     }
 
-    // Neuter the buffer now
+    // Detach the buffer now
     var data = buffer.getChannelData(0).buffer;
     worker.postMessage(data, [data]);
     // Create garbage and GC to replace the buffer data with garbage
     SpecialPowers.gc();
     createGarbage();
     SpecialPowers.gc();
 
     var source = context.createBufferSource();
--- a/dom/media/webaudio/test/test_mediaDecoding.html
+++ b/dom/media/webaudio/test/test_mediaDecoding.html
@@ -306,18 +306,18 @@ function runResampling(test, response, c
     checkResampledBuffer(asyncResult, test, callback);
   }, function onFailure() {
     ok(false, "Expected successful decode with resample");
     callback();
   });
 }
 
 function runTest(test, response, callback) {
-  // We need to copy the array here, because decodeAudioData is going to neuter
-  // the array.
+  // We need to copy the array here, because decodeAudioData will detach the
+  // array's buffer.
   var compressedAudio = response.slice(0);
   var expectCallback = false;
   var cx = new OfflineAudioContext(test.numberOfChannels || 1,
                                    test.frames || 1, test.sampleRate);
   cx.decodeAudioData(response, function onSuccess(asyncResult) {
     ok(expectCallback, "Success callback should fire asynchronously");
     ok(test.valid, "Did expect success for test " + test.url);
 
--- a/dom/tests/mochitest/whatwg/test_postMessage_transfer.html
+++ b/dom/tests/mochitest/whatwg/test_postMessage_transfer.html
@@ -32,18 +32,18 @@ var tests = [
   function() { SimpleTest.finish(); },
 ];
 
 function testFunc(target, origin) {
   var ab = new ArrayBuffer(1);
   var cd = new ArrayBuffer(1);
 
   target.postMessage([ab, cd], origin, [ab]);
-  is(ab.byteLength, 0, "ab should be neutered");
-  is(cd.byteLength, 1, "cd should not be neutered");
+  is(ab.byteLength, 0, "ab should be detached");
+  is(cd.byteLength, 1, "cd should not be detached");
 
   onmessage = function(e) {
     is(e.data[0].byteLength, 1, "ab should be transfered");
     is(e.data[1].byteLength, 1, "cd should be cloned");
     nextTest();
   };
 }
 
--- a/netwerk/test/mochitests/test_arraybufferinputstream.html
+++ b/netwerk/test/mochitests/test_arraybufferinputstream.html
@@ -3,17 +3,17 @@
 <!--
 -->
 <head>
   <title>ArrayBuffer stream test</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
-function neuter(ab)
+function detachArrayBuffer(ab)
 {
   var w = new Worker("data:application/javascript,");
   w.postMessage(ab, [ab]);
 }
 
 function test()
 {
   var ab = new ArrayBuffer(4000);
@@ -29,30 +29,30 @@ function test()
   sis.init(abis);
 
   is(sis.read(1), "", "should read no data from an uninitialized ABIS");
 
   abis.setData(ab, 0, 256 * 1024);
 
   is(sis.read(1), "a", "should read 'a' after init");
 
-  neuter(ab);
+  detachArrayBuffer(ab);
 
   SpecialPowers.forceGC();
   SpecialPowers.forceGC();
 
   try
   {
     sis.read(1);
     ok(false, "reading from stream shouldn't have worked");
   }
   catch (e)
   {
     ok(e.result === Cr.NS_BASE_STREAM_CLOSED,
-       "neutering underneath an input stream should close it");
+       "detaching underneath an input stream should close it");
   }
 }
 
 test();
 </script>
 </head>
 <body>
 <p id="display"></p>
--- a/toolkit/components/promiseworker/tests/xpcshell/test_Promise.js
+++ b/toolkit/components/promiseworker/tests/xpcshell/test_Promise.js
@@ -63,44 +63,44 @@ add_task(function* test_rejected_promise
 });
 
 // Test that we can transfer to the worker using argument `transfer`
 add_task(function* test_transfer_args() {
   let array = new Uint8Array(4);
   for (let i = 0; i < 4; ++i) {
     array[i] = i;
   }
-  Assert.equal(array.buffer.byteLength, 4, "The buffer is not neutered yet");
+  Assert.equal(array.buffer.byteLength, 4, "The buffer is not detached yet");
 
   let result = (yield worker.post("bounce", [array.buffer], [], [array.buffer]))[0];
 
   // Check that the buffer has been sent
-  Assert.equal(array.buffer.byteLength, 0, "The buffer has been neutered");
+  Assert.equal(array.buffer.byteLength, 0, "The buffer has been detached");
 
   // Check that the result is correct
   Assert.equal(result.byteLength, 4, "The result has the right size");
   let array2 = new Uint8Array(result);
   for (let i = 0; i < 4; ++i) {
     Assert.equal(array2[i], i);
   }
 });
 
 // Test that we can transfer to the worker using an instance of `Meta`
 add_task(function* test_transfer_with_meta() {
   let array = new Uint8Array(4);
   for (let i = 0; i < 4; ++i) {
     array[i] = i;
   }
-  Assert.equal(array.buffer.byteLength, 4, "The buffer is not neutered yet");
+  Assert.equal(array.buffer.byteLength, 4, "The buffer is not detached yet");
 
   let message = new BasePromiseWorker.Meta(array, {transfers: [array.buffer]});
   let result = (yield worker.post("bounce", [message]))[0];
 
   // Check that the buffer has been sent
-  Assert.equal(array.buffer.byteLength, 0, "The buffer has been neutered");
+  Assert.equal(array.buffer.byteLength, 0, "The buffer has been detached");
 
   // Check that the result is correct
   Assert.equal(result.toString(), "[object Uint8Array]", "The result appears to be a Typed Array");
   Assert.equal(result.byteLength, 4, "The result has the right size");
 
   for (let i = 0; i < 4; ++i) {
     Assert.equal(result[i], i);
   }
--- a/toolkit/components/thumbnails/PageThumbs.jsm
+++ b/toolkit/components/thumbnails/PageThumbs.jsm
@@ -598,17 +598,17 @@ this.PageThumbsStorage = {
     return rev;
   },
 
   /**
    * Write the contents of a thumbnail, off the main thread.
    *
    * @param {string} aURL The url for which to store a thumbnail.
    * @param {ArrayBuffer} aData The data to store in the thumbnail, as
-   * an ArrayBuffer. This array buffer is neutered and cannot be
+   * an ArrayBuffer. This array buffer will be detached and cannot be
    * reused after the copy.
    * @param {boolean} aNoOverwrite If true and the thumbnail's file already
    * exists, the file will not be overwritten.
    *
    * @return {Promise}
    */
   writeData: function Storage_writeData(aURL, aData, aNoOverwrite) {
     let path = this.getFilePathForURL(aURL);