author | Matthew Schranz <schranz.m@gmail.com> |
Thu, 16 Feb 2012 11:22:25 +0100 | |
changeset 86999 | 1f99e7a087c1aa99321d6cc5b4f5715db7d095fb |
parent 86998 | d2852f3e139996786a37c391135955b026451557 |
child 87000 | 69cb70c3a1e90a257d85a8db7701edc2584e4500 |
push id | 22071 |
push user | bmo@edmorley.co.uk |
push date | Fri, 17 Feb 2012 11:08:28 +0000 |
treeherder | mozilla-central@08e55f36b731 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | sicking |
bugs | 725289 |
milestone | 13.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
|
--- a/content/base/crashtests/700512-worker.js +++ b/content/base/crashtests/700512-worker.js @@ -1,7 +1,7 @@ onmessage = function(event) { var blob = event.data; - blob.mozSlice(1, 5); + blob.slice(1, 5); postMessage("done"); }
--- a/content/base/public/nsIDOMFile.idl +++ b/content/base/public/nsIDOMFile.idl @@ -66,19 +66,19 @@ interface nsIDOMBlob : nsISupports readonly attribute unsigned long long size; readonly attribute DOMString type; [noscript] readonly attribute nsIInputStream internalStream; // The caller is responsible for releasing the internalUrl from the // blob: protocol handler [noscript] DOMString getInternalUrl(in nsIPrincipal principal); - [optional_argc] nsIDOMBlob mozSlice([optional] in long long start, - [optional] in long long end, - [optional] in DOMString contentType); + [optional_argc] nsIDOMBlob slice([optional] in long long start, + [optional] in long long end, + [optional] in DOMString contentType); // Get internal id of stored file. Returns -1 if it is not a stored file. // Intended only for testing. It can be called on any thread. [notxpcom] long long getFileId(); // Called when the blob was successfully stored in a database or when // the blob is initialized from a database. It can be called on any thread. [notxpcom] void addFileInfo(in FileInfo aFileInfo);
--- a/content/base/src/nsDOMBlobBuilder.cpp +++ b/content/base/src/nsDOMBlobBuilder.cpp @@ -117,19 +117,19 @@ nsDOMMultipartFile::CreateSlice(PRUint64 PRUint64 l; nsresult rv = blob->GetSize(&l); NS_ENSURE_SUCCESS(rv, nsnull); if (skipStart < l) { PRUint64 upperBound = NS_MIN<PRUint64>(l - skipStart, length); nsCOMPtr<nsIDOMBlob> firstBlob; - rv = blob->MozSlice(skipStart, skipStart + upperBound, - aContentType, 3, - getter_AddRefs(firstBlob)); + rv = blob->Slice(skipStart, skipStart + upperBound, + aContentType, 3, + getter_AddRefs(firstBlob)); NS_ENSURE_SUCCESS(rv, nsnull); // Avoid wrapping a single blob inside an nsDOMMultipartFile if (length == upperBound) { return firstBlob.forget(); } blobs.AppendElement(firstBlob); @@ -145,18 +145,18 @@ nsDOMMultipartFile::CreateSlice(PRUint64 nsIDOMBlob* blob = mBlobs[i].get(); PRUint64 l; nsresult rv = blob->GetSize(&l); NS_ENSURE_SUCCESS(rv, nsnull); if (length < l) { nsCOMPtr<nsIDOMBlob> lastBlob; - rv = blob->MozSlice(0, length, aContentType, 3, - getter_AddRefs(lastBlob)); + rv = blob->Slice(0, length, aContentType, 3, + getter_AddRefs(lastBlob)); NS_ENSURE_SUCCESS(rv, nsnull); blobs.AppendElement(lastBlob); } else { blobs.AppendElement(blob); } length -= NS_MIN<PRUint64>(l, length); }
--- a/content/base/src/nsDOMFile.cpp +++ b/content/base/src/nsDOMFile.cpp @@ -233,19 +233,19 @@ ParseSize(PRInt64 aSize, PRInt64& aStart } else { aStart = newStartOffset.value(); aEnd = newEndOffset.value(); } } NS_IMETHODIMP -nsDOMFileBase::MozSlice(PRInt64 aStart, PRInt64 aEnd, - const nsAString& aContentType, PRUint8 optional_argc, - nsIDOMBlob **aBlob) +nsDOMFileBase::Slice(PRInt64 aStart, PRInt64 aEnd, + const nsAString& aContentType, PRUint8 optional_argc, + nsIDOMBlob **aBlob) { *aBlob = nsnull; // Truncate aStart and aEnd so that we stay within this file. PRUint64 thisLength; nsresult rv = GetSize(&thisLength); NS_ENSURE_SUCCESS(rv, rv);
--- a/content/base/test/fileutils.js +++ b/content/base/test/fileutils.js @@ -196,34 +196,34 @@ function checkMPSubmission(sub, expected } function testSlice(file, size, type, contents, fileType) { is(file.type, type, fileType + " file is correct type"); is(file.size, size, fileType + " file is correct size"); ok(file instanceof File, fileType + " file is a File"); ok(file instanceof Blob, fileType + " file is also a Blob"); - var slice = file.mozSlice(0, size); + var slice = file.slice(0, size); ok(slice instanceof Blob, fileType + " fullsize slice is a Blob"); ok(!(slice instanceof File), fileType + " fullsize slice is not a File"); - slice = file.mozSlice(0, 1234); + slice = file.slice(0, 1234); ok(slice instanceof Blob, fileType + " sized slice is a Blob"); ok(!(slice instanceof File), fileType + " sized slice is not a File"); - slice = file.mozSlice(0, size, "foo/bar"); + slice = file.slice(0, size, "foo/bar"); is(slice.type, "foo/bar", fileType + " fullsize slice foo/bar type"); - slice = file.mozSlice(0, 5432, "foo/bar"); + slice = file.slice(0, 5432, "foo/bar"); is(slice.type, "foo/bar", fileType + " sized slice foo/bar type"); - is(slice.mozSlice(0, 10).type, "", fileType + " slice-slice type"); - is(slice.mozSlice(0, 10).size, 10, fileType + " slice-slice size"); - is(slice.mozSlice(0, 10, "hello/world").type, "hello/world", fileType + " slice-slice hello/world type"); - is(slice.mozSlice(0, 10, "hello/world").size, 10, fileType + " slice-slice hello/world size"); + is(slice.slice(0, 10).type, "", fileType + " slice-slice type"); + is(slice.slice(0, 10).size, 10, fileType + " slice-slice size"); + is(slice.slice(0, 10, "hello/world").type, "hello/world", fileType + " slice-slice hello/world type"); + is(slice.slice(0, 10, "hello/world").size, 10, fileType + " slice-slice hello/world size"); // Start, end, expected size var indexes = [[0, size, size], [0, 1234, 1234], [size-500, size, 500], [size-500, size+500, 500], [size+500, size+1500, 0], [0, 0, 0], @@ -242,38 +242,38 @@ function testSlice(file, size, type, con [0, 33000, 33000], [1000, 34000, 33000], ]; for (var i = 0; i < indexes.length; ++i) { var sliceContents; var testName; if (indexes[i][0] == undefined) { - slice = file.mozSlice(); + slice = file.slice(); sliceContents = contents.slice(); testName = fileType + " slice()"; } else if (indexes[i][1] == undefined) { - slice = file.mozSlice(indexes[i][0]); + slice = file.slice(indexes[i][0]); sliceContents = contents.slice(indexes[i][0]); testName = fileType + " slice(" + indexes[i][0] + ")"; } else { - slice = file.mozSlice(indexes[i][0], indexes[i][1]); + slice = file.slice(indexes[i][0], indexes[i][1]); sliceContents = contents.slice(indexes[i][0], indexes[i][1]); testName = fileType + " slice(" + indexes[i][0] + ", " + indexes[i][1] + ")"; } is(slice.type, "", testName + " type"); is(slice.size, indexes[i][2], testName + " size"); is(sliceContents.length, indexes[i][2], testName + " data size"); testFile(slice, sliceContents, testName); } // Slice of slice - var slice = file.mozSlice(0, 40000); - testFile(slice.mozSlice(5000, 42000), contents.slice(5000, 40000), "file slice slice"); + var slice = file.slice(0, 40000); + testFile(slice.slice(5000, 42000), contents.slice(5000, 40000), "file slice slice"); // ...of slice of slice - slice = slice.mozSlice(5000, 42000).mozSlice(400, 700); + slice = slice.slice(5000, 42000).mozSlice(400, 700); SpecialPowers.gc(); testFile(slice, contents.slice(5400, 5700), "file slice slice slice"); }
--- a/content/base/test/test_blobbuilder.html +++ b/content/base/test/test_blobbuilder.html @@ -146,17 +146,17 @@ function doTest(data) { blobs.forEach(doAppend); ok(true, "Test " + testCounter + " appended all successfully"); let blob = bb.getBlob(); ok(blob, "Test " + testCounter + " got blob"); ok(blob instanceof Blob, "Test " + testCounter + " blob is a Blob"); ok(!(blob instanceof File), "Test " + testCounter + " blob is not a File"); - let slice = blob.mozSlice(test.start, test.start + test.length); + let slice = blob.slice(test.start, test.start + test.length); ok(slice, "Test " + testCounter + " got slice"); ok(slice instanceof Blob, "Test " + testCounter + " slice is a Blob"); ok(!(slice instanceof File), "Test " + testCounter + " slice is not a File"); is(slice.size, test.contents.length, "Test " + testCounter + " slice is correct size"); testFile(slice, test.contents, "Test " + testCounter); }
--- a/content/base/test/test_fileapi_slice.html +++ b/content/base/test/test_fileapi_slice.html @@ -99,39 +99,39 @@ function imageLoadHandler(event) { testHasRun(); } // image in the middle var imgfile = createFileWithData(testBinaryData + fileData + testBinaryData); is(imgfile.size, size + testBinaryData.length * 2, "correct file size (middle)"); var img = new Image; -img.src = URL.createObjectURL(imgfile.mozSlice(testBinaryData.length, testBinaryData.length + size)); +img.src = URL.createObjectURL(imgfile.slice(testBinaryData.length, testBinaryData.length + size)); img.onload = imageLoadHandler; expectedTestCount++; // image at start var imgfile = createFileWithData(fileData + testBinaryData); is(imgfile.size, size + testBinaryData.length, "correct file size (start)"); var img = new Image; -img.src = URL.createObjectURL(imgfile.mozSlice(0, size)); +img.src = URL.createObjectURL(imgfile.slice(0, size)); img.onload = imageLoadHandler; expectedTestCount++; // image at end var imgfile = createFileWithData(testBinaryData + fileData); is(imgfile.size, size + testBinaryData.length, "correct file size (end)"); var img = new Image; -img.src = URL.createObjectURL(imgfile.mozSlice(testBinaryData.length, testBinaryData.length + size)); +img.src = URL.createObjectURL(imgfile.slice(testBinaryData.length, testBinaryData.length + size)); img.onload = imageLoadHandler; expectedTestCount++; // image past end var imgfile = createFileWithData(testBinaryData + fileData); is(imgfile.size, size + testBinaryData.length, "correct file size (past end)"); var img = new Image; -img.src = URL.createObjectURL(imgfile.mozSlice(testBinaryData.length, testBinaryData.length + size + 1000)); +img.src = URL.createObjectURL(imgfile.slice(testBinaryData.length, testBinaryData.length + size + 1000)); img.onload = imageLoadHandler; expectedTestCount++; </script> </pre> </body> </html>
--- a/dom/workers/File.cpp +++ b/dom/workers/File.cpp @@ -166,24 +166,24 @@ private: } *aVp = STRING_TO_JSVAL(jsType); return true; } static JSBool - MozSlice(JSContext* aCx, uintN aArgc, jsval* aVp) + Slice(JSContext* aCx, uintN aArgc, jsval* aVp) { JSObject* obj = JS_THIS_OBJECT(aCx, aVp); if (!obj) { return false; } - nsIDOMBlob* blob = GetInstancePrivate(aCx, obj, "mozSlice"); + nsIDOMBlob* blob = GetInstancePrivate(aCx, obj, "slice"); if (!blob) { return false; } jsdouble start = 0, end = 0; JSString* jsContentType = JS_GetEmptyString(JS_GetRuntime(aCx)); if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "/IIS", &start, &end, &jsContentType)) { @@ -192,20 +192,20 @@ private: nsDependentJSString contentType; if (!contentType.init(aCx, jsContentType)) { return false; } PRUint8 optionalArgc = aArgc; nsCOMPtr<nsIDOMBlob> rtnBlob; - if (NS_FAILED(blob->MozSlice(static_cast<PRUint64>(start), - static_cast<PRUint64>(end), - contentType, optionalArgc, - getter_AddRefs(rtnBlob)))) { + if (NS_FAILED(blob->Slice(static_cast<PRUint64>(start), + static_cast<PRUint64>(end), + contentType, optionalArgc, + getter_AddRefs(rtnBlob)))) { ThrowFileExceptionForCode(aCx, FILE_NOT_READABLE_ERR); return false; } JSObject* rtnObj = file::CreateBlob(aCx, rtnBlob); if (!rtnObj) { return false; } @@ -225,17 +225,17 @@ JSClass Blob::sClass = { JSPropertySpec Blob::sProperties[] = { { "size", 0, PROPERTY_FLAGS, GetSize, js_GetterOnlyPropertyStub }, { "type", 0, PROPERTY_FLAGS, GetType, js_GetterOnlyPropertyStub }, { 0, 0, 0, NULL, NULL } }; JSFunctionSpec Blob::sFunctions[] = { - JS_FN("mozSlice", MozSlice, 1, JSPROP_ENUMERATE), + JS_FN("slice", Slice, 1, JSPROP_ENUMERATE), JS_FS_END }; class File : public Blob { // File should never be instantiated. File(); ~File();
--- a/dom/workers/test/Makefile.in +++ b/dom/workers/test/Makefile.in @@ -131,31 +131,31 @@ include $(topsrcdir)/config/rules.mk $(NULL) _CHROME_TEST_FILES = \ test_chromeWorker.xul \ test_chromeWorkerJSM.xul \ test_extension.xul \ test_extensionBootstrap.xul \ test_file.xul \ - test_fileMozSlice.xul \ + test_fileSlice.xul \ test_fileBlobPosting.xul \ test_filePosting.xul \ test_fileReaderSync.xul \ test_fileReaderSyncErrors.xul \ - test_fileReadMozSlice.xul \ + test_fileReadSlice.xul \ test_fileSubWorker.xul \ test_fileBlobSubWorker.xul \ file_worker.js \ fileBlob_worker.js \ - fileMozSlice_worker.js \ + fileSlice_worker.js \ filePosting_worker.js \ fileReaderSync_worker.js \ fileReaderSyncErrors_worker.js \ - fileReadMozSlice_worker.js \ + fileReadSlice_worker.js \ fileSubWorker_worker.js \ fileBlobSubWorker_worker.js \ WorkerTest.jsm \ WorkerTest_worker.js \ WorkerTest_subworker.js \ chromeWorker_worker.js \ chromeWorker_subworker.js \ test_workersDisabled.xul \
rename from dom/workers/test/fileReadMozSlice_worker.js rename to dom/workers/test/fileReadSlice_worker.js --- a/dom/workers/test/fileReadMozSlice_worker.js +++ b/dom/workers/test/fileReadSlice_worker.js @@ -2,15 +2,15 @@ * Expects an object containing a blob, a start index and an end index * for slicing. Returns the contents of the blob read as text. */ onmessage = function(event) { var blob = event.data.blob; var start = event.data.start; var end = event.data.end; - var slicedBlob = blob.mozSlice(start, end); + var slicedBlob = blob.slice(start, end); var fileReader = new FileReaderSync(); var text = fileReader.readAsText(slicedBlob); postMessage(text); };
rename from dom/workers/test/fileMozSlice_worker.js rename to dom/workers/test/fileSlice_worker.js --- a/dom/workers/test/fileMozSlice_worker.js +++ b/dom/workers/test/fileSlice_worker.js @@ -6,21 +6,21 @@ onmessage = function(event) { var blob = event.data.blob; var start = event.data.start; var end = event.data.end; var contentType = event.data.contentType; var slicedBlob; if (contentType == undefined && end == undefined) { - slicedBlob = blob.mozSlice(start); + slicedBlob = blob.slice(start); } else if (contentType == undefined) { - slicedBlob = blob.mozSlice(start, end); + slicedBlob = blob.slice(start, end); } else { - slicedBlob = blob.mozSlice(start, end, contentType); + slicedBlob = blob.slice(start, end, contentType); } var rtnObj = new Object(); rtnObj.size = slicedBlob.size; rtnObj.type = slicedBlob.type; postMessage(rtnObj);
--- a/dom/workers/test/test_fileBlobPosting.xul +++ b/dom/workers/test/test_fileBlobPosting.xul @@ -65,17 +65,17 @@ https://bugzilla.mozilla.org/show_bug.cg }; worker.onmessage = function(event) { console.log(event.data); is(event.data.size, file.size, "size of file posted from worker does not match file posted to worker."); finish(); }; - var blob = file.mozSlice(); + var blob = file.slice(); worker.postMessage(blob); waitForWorkerFinish(); } // Empty file. postBlob(createFileWithData("")); // Typical use case.
--- a/dom/workers/test/test_fileBlobSubWorker.xul +++ b/dom/workers/test/test_fileBlobSubWorker.xul @@ -67,17 +67,17 @@ https://bugzilla.mozilla.org/show_bug.cg if (event.data == undefined) { ok(false, "Worker had an error."); } else { is(event.data.size, expectedSize, "size proproperty accessed from worker is not the same as on main thread."); } finish(); }; - var blob = file.mozSlice(); + var blob = file.slice(); worker.postMessage(blob); waitForWorkerFinish(); } // Empty file. accessFileProperties(createFileWithData(""), 0); // Typical use case.
rename from dom/workers/test/test_fileReadMozSlice.xul rename to dom/workers/test/test_fileReadSlice.xul --- a/dom/workers/test/test_fileReadMozSlice.xul +++ b/dom/workers/test/test_fileReadSlice.xul @@ -31,17 +31,17 @@ https://bugzilla.mozilla.org/show_bug.cg /** * Create a file which contains the given data. */ function createFileWithData(fileData) { var testFile = Components.classes["@mozilla.org/file/directory_service;1"] .getService(Components.interfaces.nsIProperties) .get("ProfD", Components.interfaces.nsIFile); - testFile.append("workerReadMozSlice" + fileNum++); + testFile.append("workerReadSlice" + fileNum++); var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"] .createInstance(Components.interfaces.nsIFileOutputStream); outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate 0666, 0); outStream.write(fileData, fileData.length); outStream.close(); @@ -50,18 +50,18 @@ https://bugzilla.mozilla.org/show_bug.cg return fileList.files[0]; } /** * Creates a worker which slices a blob to the given start and end offset and * reads the content as text. */ - function readMozSlice(blob, start, end, expectedText) { - var worker = new Worker("fileReadMozSlice_worker.js"); + function readSlice(blob, start, end, expectedText) { + var worker = new Worker("fileReadSlice_worker.js"); worker.onerror = function(event) { ok(false, "Worker had an error: " + event.data); finish(); }; worker.onmessage = function(event) { is(event.data, expectedText, "Text from sliced blob in worker is incorrect."); @@ -69,22 +69,22 @@ https://bugzilla.mozilla.org/show_bug.cg }; var params = {blob: blob, start: start, end: end}; worker.postMessage(params); waitForWorkerFinish(); } // Empty file. - readMozSlice(createFileWithData(""), 0, 0, ""); + readSlice(createFileWithData(""), 0, 0, ""); // Typical use case. - readMozSlice(createFileWithData("HelloBye"), 5, 8, "Bye"); + readSlice(createFileWithData("HelloBye"), 5, 8, "Bye"); // End offset too large. - readMozSlice(createFileWithData("HelloBye"), 5, 9, "Bye"); + readSlice(createFileWithData("HelloBye"), 5, 9, "Bye"); // Start of file. - readMozSlice(createFileWithData("HelloBye"), 0, 5, "Hello"); + readSlice(createFileWithData("HelloBye"), 0, 5, "Hello"); ]]> </script> </window>
rename from dom/workers/test/test_fileMozSlice.xul rename to dom/workers/test/test_fileSlice.xul --- a/dom/workers/test/test_fileMozSlice.xul +++ b/dom/workers/test/test_fileSlice.xul @@ -32,17 +32,17 @@ https://bugzilla.mozilla.org/show_bug.cg /** * Create a file which contains the given data and optionally adds the specified file extension. */ function createFileWithData(fileData, /** optional */ extension) { var testFile = Components.classes["@mozilla.org/file/directory_service;1"] .getService(Components.interfaces.nsIProperties) .get("ProfD", Components.interfaces.nsIFile); var fileExtension = (extension == undefined) ? "" : "." + extension; - testFile.append("workerMozSlice" + fileNum++ + fileExtension); + testFile.append("workerSlice" + fileNum++ + fileExtension); var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"] .createInstance(Components.interfaces.nsIFileOutputStream); outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate 0666, 0); outStream.write(fileData, fileData.length); outStream.close(); @@ -51,18 +51,18 @@ https://bugzilla.mozilla.org/show_bug.cg return fileList.files[0]; } /** * Starts a worker which slices the blob to the given start offset and optional end offset and * content type. It then verifies that the size and type of the sliced blob is correct. */ - function createMozSlice(blob, start, expectedLength, /** optional */ end, /** optional */ contentType) { - var worker = new Worker("fileMozSlice_worker.js"); + function createSlice(blob, start, expectedLength, /** optional */ end, /** optional */ contentType) { + var worker = new Worker("fileSlice_worker.js"); worker.onerror = function(event) { ok(false, "Worker had an error: " + event.data); finish(); }; worker.onmessage = function(event) { is(event.data.size, expectedLength, "size property of slice is incorrect."); @@ -71,36 +71,36 @@ https://bugzilla.mozilla.org/show_bug.cg }; var params = {blob: blob, start: start, end: end, contentType: contentType}; worker.postMessage(params); waitForWorkerFinish(); } // Empty file. - createMozSlice(createFileWithData(""), 0, 0, 0); + createSlice(createFileWithData(""), 0, 0, 0); // Typical use case. - createMozSlice(createFileWithData("Hello"), 1, 1, 2); + createSlice(createFileWithData("Hello"), 1, 1, 2); // Longish file. var text = ""; for (var i = 0; i < 10000; ++i) { text += "long"; } - createMozSlice(createFileWithData(text), 2000, 2000, 4000); + createSlice(createFileWithData(text), 2000, 2000, 4000); // Slice to different type. - createMozSlice(createFileWithData("text", "txt"), 0, 2, 2, "image/png"); + createSlice(createFileWithData("text", "txt"), 0, 2, 2, "image/png"); // Length longer than blob. - createMozSlice(createFileWithData("text"), 0, 4, 20); + createSlice(createFileWithData("text"), 0, 4, 20); // Start longer than blob. - createMozSlice(createFileWithData("text"), 20, 0, 4); + createSlice(createFileWithData("text"), 20, 0, 4); // No optional arguments - createMozSlice(createFileWithData("text"), 0, 4); - createMozSlice(createFileWithData("text"), 2, 2); + createSlice(createFileWithData("text"), 0, 4); + createSlice(createFileWithData("text"), 2, 2); ]]> </script> </window>