Bug 736687 - Warn on use of MozBlobBuilder. r=sicking

--HG--
rename : layout/reftests/svg/as-image/img-blobBuilder-1.html => layout/reftests/svg/as-image/img-blobURI-1.html
rename : layout/reftests/svg/as-image/img-blobBuilder-2.html => layout/reftests/svg/as-image/img-blobURI-2.html
This commit is contained in:
Masatoshi Kimura 2012-03-19 12:00:43 +01:00
Родитель 2c3301cdb1
Коммит d5f85c93cb
12 изменённых файлов: 54 добавлений и 41 удалений

Просмотреть файл

@ -2,15 +2,10 @@
<script type="text/javascript"> <script type="text/javascript">
var worker = new Worker("700512-worker.js"); var worker = new Worker("700512-worker.js");
var bb = new MozBlobBuilder();
bb.append("foo");
bb.append("bar");
worker.onmessage = function() { worker.onmessage = function() {
document.documentElement.removeAttribute("class"); document.documentElement.removeAttribute("class");
} }
worker.postMessage(bb.getBlob()); worker.postMessage(new Blob(["foo", "bar"]));
</script> </script>
</html> </html>

Просмотреть файл

@ -75,3 +75,4 @@ DEPRECATED_OPERATION(Position)
DEPRECATED_OPERATION(TotalSize) DEPRECATED_OPERATION(TotalSize)
DEPRECATED_OPERATION(InputEncoding) DEPRECATED_OPERATION(InputEncoding)
DEPRECATED_OPERATION(MozBeforePaint) DEPRECATED_OPERATION(MozBeforePaint)
DEPRECATED_OPERATION(MozBlobBuilder)

Просмотреть файл

@ -45,6 +45,7 @@
#include "nsJSUtils.h" #include "nsJSUtils.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "DictionaryHelpers.h" #include "DictionaryHelpers.h"
#include "nsIScriptError.h"
using namespace mozilla; using namespace mozilla;
@ -326,7 +327,8 @@ NS_IMPL_ADDREF(nsDOMBlobBuilder)
NS_IMPL_RELEASE(nsDOMBlobBuilder) NS_IMPL_RELEASE(nsDOMBlobBuilder)
NS_INTERFACE_MAP_BEGIN(nsDOMBlobBuilder) NS_INTERFACE_MAP_BEGIN(nsDOMBlobBuilder)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozBlobBuilder) NS_INTERFACE_MAP_ENTRY(nsIDOMMozBlobBuilder)
NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMozBlobBuilder)
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozBlobBuilder) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozBlobBuilder)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
@ -438,3 +440,24 @@ nsresult NS_NewBlobBuilder(nsISupports* *aSupports)
nsDOMBlobBuilder* builder = new nsDOMBlobBuilder(); nsDOMBlobBuilder* builder = new nsDOMBlobBuilder();
return CallQueryInterface(builder, aSupports); return CallQueryInterface(builder, aSupports);
} }
NS_IMETHODIMP
nsDOMBlobBuilder::Initialize(nsISupports* aOwner,
JSContext* aCx,
JSObject* aObj,
PRUint32 aArgc,
jsval* aArgv)
{
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(aOwner));
if (!window) {
return NS_OK;
}
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
if (!doc) {
return NS_OK;
}
doc->WarnOnceAbout(nsIDocument::eMozBlobBuilder);
return NS_OK;
}

Просмотреть файл

@ -159,7 +159,8 @@ protected:
PRUint64 mDataBufferLen; PRUint64 mDataBufferLen;
}; };
class nsDOMBlobBuilder : public nsIDOMMozBlobBuilder class nsDOMBlobBuilder : public nsIDOMMozBlobBuilder,
public nsIJSNativeInitializer
{ {
public: public:
nsDOMBlobBuilder() nsDOMBlobBuilder()
@ -174,6 +175,13 @@ public:
nsresult GetBlobInternal(const nsAString& aContentType, nsresult GetBlobInternal(const nsAString& aContentType,
bool aClearBuffer, nsIDOMBlob** aBlob); bool aClearBuffer, nsIDOMBlob** aBlob);
// nsIJSNativeInitializer
NS_IMETHOD Initialize(nsISupports* aOwner,
JSContext* aCx,
JSObject* aObj,
PRUint32 aArgc,
jsval* aArgv);
protected: protected:
BlobSet mBlobSet; BlobSet mBlobSet;
}; };

Просмотреть файл

@ -8248,10 +8248,10 @@ void
nsIDocument::WarnOnceAbout(DeprecatedOperations aOperation) nsIDocument::WarnOnceAbout(DeprecatedOperations aOperation)
{ {
PR_STATIC_ASSERT(eDeprecatedOperationCount <= 64); PR_STATIC_ASSERT(eDeprecatedOperationCount <= 64);
if (mWarnedAbout & (1 << aOperation)) { if (mWarnedAbout & (1ull << aOperation)) {
return; return;
} }
mWarnedAbout |= (1 << aOperation); mWarnedAbout |= (1ull << aOperation);
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
"DOM Core", this, "DOM Core", this,
nsContentUtils::eDOM_PROPERTIES, nsContentUtils::eDOM_PROPERTIES,

Просмотреть файл

@ -3,7 +3,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/ * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
var builder = new MozBlobBuilder();
var manager = null; var manager = null;
var bufferCache = []; var bufferCache = [];
var utils = SpecialPowers.getDOMWindowUtils(window); var utils = SpecialPowers.getDOMWindowUtils(window);
@ -42,14 +41,12 @@ function compareBuffers(buffer1, buffer2)
function getBlob(type, buffer) function getBlob(type, buffer)
{ {
builder.append(buffer); return new Blob([buffer], {type: type});
return builder.getBlob(type);
} }
function getFile(name, type, buffer) function getFile(name, type, buffer)
{ {
builder.append(buffer); return new Blob([buffer], {type: type});
return builder.getFile(name, type);
} }
function getRandomBlob(size) function getRandomBlob(size)

Просмотреть файл

@ -61,9 +61,6 @@
refResult = result; refResult = result;
continue; continue;
} }
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
isnot(result.mozFullPath, refResult.mozFullPath, "Different os files");
} }
for (let i = 1; i < databases.length; i++) { for (let i = 1; i < databases.length; i++) {
@ -85,9 +82,6 @@
let result = event.target.result; let result = event.target.result;
verifyBlob(result, refResult, 2); verifyBlob(result, refResult, 2);
yield; yield;
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
isnot(result.mozFullPath, refResult.mozFullPath, "Different os files");
} }
is(bufferCache.length, 2, "Correct length"); is(bufferCache.length, 2, "Correct length");

Просмотреть файл

@ -148,3 +148,5 @@ MediaLoadUnsupportedType=Specified "type" of "%1$S" is not supported. Load of me
MediaLoadUnsupportedMimeType=HTTP "Content-Type" of "%1$S" is not supported. Load of media resource %2$S failed. MediaLoadUnsupportedMimeType=HTTP "Content-Type" of "%1$S" is not supported. Load of media resource %2$S failed.
# LOCALIZATION NOTE: %S is the URL of the media resource which failed to load because of error in decoding. # LOCALIZATION NOTE: %S is the URL of the media resource which failed to load because of error in decoding.
MediaLoadDecodeError=Media resource %S could not be decoded. MediaLoadDecodeError=Media resource %S could not be decoded.
# LOCALIZATION NOTE: Do not translate "MozBlobBuilder" and "Blob"
MozBlobBuilderWarning=Use of MozBlobBuilder is deprecated. Use Blob constructor instead.

Просмотреть файл

@ -18,10 +18,7 @@
" postMessage(event.data);" + " postMessage(event.data);" +
"};"; "};";
var bb = new MozBlobBuilder(); var worker = new Worker(URL.createObjectURL(new Blob([workerScript])));
bb.append(workerScript);
var worker = new Worker(URL.createObjectURL(bb.getBlob()));
worker.onmessage = function(event) { worker.onmessage = function(event) {
is(event.data, message, "Got correct message"); is(event.data, message, "Got correct message");
SimpleTest.finish(); SimpleTest.finish();

Просмотреть файл

@ -1,16 +1,16 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- This test checks to be sure we can render SVG-as-an-image <!-- This test checks to be sure we can render SVG-as-an-image
from a MozBlobBuilder-generated 'blob' URI. --> from a 'blob' URI. -->
<html class="reftest-wait"> <html class="reftest-wait">
<head> <head>
<script> <script>
function go() { function go() {
// Generate a blob URL encoding of an SVG document // Generate a blob URL encoding of an SVG document
var filedataURL = generateMozFiledataURL(); var blobURL = generateBlobURL();
// Tell our img element to render the URL // Tell our img element to render the URL
var img = document.getElementsByTagName("img")[0] var img = document.getElementsByTagName("img")[0]
img.src = filedataURL; img.src = blobURL;
// Once our img loads, take reftest snapshot. // Once our img loads, take reftest snapshot.
img.addEventListener("load", function() { img.addEventListener("load", function() {
@ -20,14 +20,12 @@
// Helper function -- returns a blob URL representing a // Helper function -- returns a blob URL representing a
// 100x100 fully-lime SVG document. // 100x100 fully-lime SVG document.
function generateMozFiledataURL() { function generateBlobURL() {
var blobBuilder = new self.MozBlobBuilder;
var svg = var svg =
'<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">' + '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">' +
'<rect height="100%" width="100%" fill="lime"/>' + '<rect height="100%" width="100%" fill="lime"/>' +
'</svg>'; '</svg>';
blobBuilder.append(svg); return self.URL.createObjectURL(new Blob([svg], {type: "image/svg+xml"}));
return self.URL.createObjectURL(blobBuilder.getBlob("image/svg+xml"));
} }
</script> </script>
</head> </head>

Просмотреть файл

@ -1,12 +1,12 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- This test checks to be sure we allow MozBlobBuilder-generated <!-- This test checks to be sure we allow
'blob' URIs *inside of* SVG-as-an-image. --> 'blob' URIs *inside of* SVG-as-an-image. -->
<html class="reftest-wait"> <html class="reftest-wait">
<head> <head>
<script> <script>
function go() { function go() {
// Generate a blob URL encoding of an SVG document // Generate a blob URL encoding of an SVG document
var filedataURL = generateMozFiledataURL(); var blobURL = generateBlobURL();
// Now generate a data URI, containing our blob URI // Now generate a data URI, containing our blob URI
var outerSVG = var outerSVG =
@ -14,7 +14,7 @@
'xmlns:xlink="http://www.w3.org/1999/xlink" ' + 'xmlns:xlink="http://www.w3.org/1999/xlink" ' +
'width="100" height="100">' + 'width="100" height="100">' +
'<image height="100" width="100" ' + '<image height="100" width="100" ' +
'xlink:href="' + filedataURL + '"/>' + 'xlink:href="' + blobURL + '"/>' +
'</svg>'; '</svg>';
// Tell our img element to render the URL // Tell our img element to render the URL
@ -29,14 +29,12 @@
// Helper function -- returns a blob URL representing a // Helper function -- returns a blob URL representing a
// 100x100 fully-lime SVG document. // 100x100 fully-lime SVG document.
function generateMozFiledataURL() { function generateBlobURL() {
var blobBuilder = new self.MozBlobBuilder;
var svg = var svg =
'<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">' + '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">' +
'<rect height="100%" width="100%" fill="lime"/>' + '<rect height="100%" width="100%" fill="lime"/>' +
'</svg>'; '</svg>';
blobBuilder.append(svg); return self.URL.createObjectURL(new Blob([svg], {type: "image/svg+xml"}));
return self.URL.createObjectURL(blobBuilder.getBlob("image/svg+xml"));
} }
</script> </script>
</head> </head>

Просмотреть файл

@ -57,8 +57,8 @@ fails-if(!azureQuartz) == canvas-drawImage-slice-1b.html lime100x100-ref.html #
random == img-and-image-1.html img-and-image-1-ref.svg # bug 645267 random == img-and-image-1.html img-and-image-1-ref.svg # bug 645267
# More complex <img> tests # More complex <img> tests
== img-blobBuilder-1.html lime100x100-ref.html == img-blobURI-1.html lime100x100-ref.html
== img-blobBuilder-2.html lime100x100-ref.html == img-blobURI-2.html lime100x100-ref.html
== img-content-outside-viewBox-1.html img-content-outside-viewBox-1-ref.html == img-content-outside-viewBox-1.html img-content-outside-viewBox-1-ref.html
== img-dyn-1.html img-dyn-1-ref.html == img-dyn-1.html img-dyn-1-ref.html
== img-foreignObject-1.html lime100x100-ref.html == img-foreignObject-1.html lime100x100-ref.html