From abf5fa5994e13082e9f9e41239e2c439ad0bfca6 Mon Sep 17 00:00:00 2001 From: Jonas Sicking Date: Tue, 23 Nov 2010 00:50:55 -0800 Subject: [PATCH] Bug 609030: Update createBlobURL/revokeBlobURL to it's final name. r=jst a=blocker --- .../base/src/nsFileDataProtocolHandler.cpp | 16 +++ content/base/src/nsFileDataProtocolHandler.h | 1 + content/base/test/test_fileapi_slice.html | 12 +- content/base/test/test_mozfiledataurl.html | 22 ++-- dom/base/nsDOMClassInfo.cpp | 7 + dom/base/nsDOMClassInfoClasses.h | 1 + dom/base/nsGlobalWindow.cpp | 121 +++++++++++++++--- dom/base/nsGlobalWindow.h | 9 ++ dom/interfaces/base/nsIDOMWindow2.idl | 7 +- dom/interfaces/base/nsIDOMWindowInternal.idl | 13 ++ 10 files changed, 167 insertions(+), 42 deletions(-) diff --git a/content/base/src/nsFileDataProtocolHandler.cpp b/content/base/src/nsFileDataProtocolHandler.cpp index ef816a0dc5b4..917801372223 100644 --- a/content/base/src/nsFileDataProtocolHandler.cpp +++ b/content/base/src/nsFileDataProtocolHandler.cpp @@ -91,6 +91,22 @@ nsFileDataProtocolHandler::RemoveFileDataEntry(nsACString& aUri) } } +nsIPrincipal* +nsFileDataProtocolHandler::GetFileDataEntryPrincipal(nsACString& aUri) +{ + if (!gFileDataTable) { + return nsnull; + } + + FileDataInfo* res; + gFileDataTable->Get(aUri, &res); + if (!res) { + return nsnull; + } + + return res->mPrincipal; +} + static FileDataInfo* GetFileDataInfo(const nsACString& aUri) { diff --git a/content/base/src/nsFileDataProtocolHandler.h b/content/base/src/nsFileDataProtocolHandler.h index 3ff53890cf59..d3da4b02eef8 100644 --- a/content/base/src/nsFileDataProtocolHandler.h +++ b/content/base/src/nsFileDataProtocolHandler.h @@ -61,6 +61,7 @@ public: nsIDOMBlob* aFile, nsIPrincipal* aPrincipal); static void RemoveFileDataEntry(nsACString& aUri); + static nsIPrincipal* GetFileDataEntryPrincipal(nsACString& aUri); }; diff --git a/content/base/test/test_fileapi_slice.html b/content/base/test/test_fileapi_slice.html index 8b52e7d8853c..2f1f27f7612f 100644 --- a/content/base/test/test_fileapi_slice.html +++ b/content/base/test/test_fileapi_slice.html @@ -197,7 +197,7 @@ function imageLoadHandler(event) { var imgfile = createFileWithData(testBinaryData + fileData + testBinaryData); is(imgfile.size, size + testBinaryData.length * 2, "correct file size"); var img = new Image; -img.src = createBlobURL(imgfile.slice(testBinaryData.length, size)); +img.src = URL.createObjectURL(imgfile.slice(testBinaryData.length, size)); img.onload = imageLoadHandler; expectedTestCount++; @@ -205,7 +205,7 @@ expectedTestCount++; var imgfile = createFileWithData(fileData + testBinaryData); is(imgfile.size, size + testBinaryData.length, "correct file size"); var img = new Image; -img.src = createBlobURL(imgfile.slice(0, size)); +img.src = URL.createObjectURL(imgfile.slice(0, size)); img.onload = imageLoadHandler; expectedTestCount++; @@ -213,7 +213,7 @@ expectedTestCount++; var imgfile = createFileWithData(testBinaryData + fileData); is(imgfile.size, size + testBinaryData.length, "correct file size"); var img = new Image; -img.src = createBlobURL(imgfile.slice(testBinaryData.length, size)); +img.src = URL.createObjectURL(imgfile.slice(testBinaryData.length, size)); img.onload = imageLoadHandler; expectedTestCount++; @@ -221,7 +221,7 @@ expectedTestCount++; var imgfile = createFileWithData(testBinaryData + fileData); is(imgfile.size, size + testBinaryData.length, "correct file size"); var img = new Image; -img.src = createBlobURL(imgfile.slice(testBinaryData.length, size + 1000)); +img.src = URL.createObjectURL(imgfile.slice(testBinaryData.length, size + 1000)); img.onload = imageLoadHandler; expectedTestCount++; @@ -234,9 +234,9 @@ function testFile(file, contents, test) { r.readAsBinaryString(file); expectedTestCount++; - // Load file using createBlobURL and XMLHttpRequest + // Load file using URL.createObjectURL and XMLHttpRequest var xhr = new XMLHttpRequest; - xhr.open("GET", createBlobURL(file)); + xhr.open("GET", URL.createObjectURL(file)); xhr.onload = getXHRLoadHandler(contents, contents.length, false, "XMLHttpRequest load of " + test); xhr.overrideMimeType('text/plain; charset=x-user-defined'); diff --git a/content/base/test/test_mozfiledataurl.html b/content/base/test/test_mozfiledataurl.html index 35d786d14c3f..c32cf3547157 100644 --- a/content/base/test/test_mozfiledataurl.html +++ b/content/base/test/test_mozfiledataurl.html @@ -22,7 +22,7 @@