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
parent 2c3301cdb1
commit d5f85c93cb
12 changed files with 54 additions and 41 deletions

View File

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

View File

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

View File

@ -45,6 +45,7 @@
#include "nsJSUtils.h"
#include "nsContentUtils.h"
#include "DictionaryHelpers.h"
#include "nsIScriptError.h"
using namespace mozilla;
@ -326,7 +327,8 @@ NS_IMPL_ADDREF(nsDOMBlobBuilder)
NS_IMPL_RELEASE(nsDOMBlobBuilder)
NS_INTERFACE_MAP_BEGIN(nsDOMBlobBuilder)
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_INTERFACE_MAP_END
@ -438,3 +440,24 @@ nsresult NS_NewBlobBuilder(nsISupports* *aSupports)
nsDOMBlobBuilder* builder = new nsDOMBlobBuilder();
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;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -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.
# 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.
# LOCALIZATION NOTE: Do not translate "MozBlobBuilder" and "Blob"
MozBlobBuilderWarning=Use of MozBlobBuilder is deprecated. Use Blob constructor instead.

View File

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

View File

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

View File

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

View File

@ -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
# More complex <img> tests
== img-blobBuilder-1.html lime100x100-ref.html
== img-blobBuilder-2.html lime100x100-ref.html
== img-blobURI-1.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-dyn-1.html img-dyn-1-ref.html
== img-foreignObject-1.html lime100x100-ref.html