This commit is contained in:
Phil Ringnalda 2014-03-16 21:55:27 -07:00
Родитель d6939e07f3 ce1c96e4f6
Коммит b676e87405
36 изменённых файлов: 313 добавлений и 254 удалений

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

@ -263,7 +263,6 @@ skip-if = true # disabled until the tree view is added
# it ever is (bug 480169)
[browser_save_link-perwindowpb.js]
[browser_save_private_link_perwindowpb.js]
skip-if = os == "linux" # bug 857427
[browser_save_video.js]
[browser_scope.js]
[browser_selectTabAtIndex.js]

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

@ -36,45 +36,13 @@ function test() {
storage.asyncVisitStorage(new Visitor(), true /* Do walk entries */);
}
function contextMenuOpened(aWindow, event) {
cache.clear();
event.currentTarget.removeEventListener("popupshown", contextMenuOpened);
// Create the folder the image will be saved into.
var destDir = createTemporarySaveDirectory();
var destFile = destDir.clone();
MockFilePicker.displayDirectory = destDir;
MockFilePicker.showCallback = function(fp) {
fileName = fp.defaultString;
destFile.append (fileName);
MockFilePicker.returnFiles = [destFile];
MockFilePicker.filterIndex = 1; // kSaveAsType_URL
};
mockTransferCallback = onTransferComplete;
mockTransferRegisterer.register();
registerCleanupFunction(function () {
mockTransferRegisterer.unregister();
MockFilePicker.cleanup();
destDir.remove(true);
});
// Select "Save Image As" option from context menu
var saveVideoCommand = aWindow.document.getElementById("context-saveimage");
saveVideoCommand.doCommand();
event.target.hidePopup();
}
function onTransferComplete(downloadSuccess) {
ok(downloadSuccess, "Image file should have been downloaded successfully");
// Give the request a chance to finish and create a cache entry
executeSoon(function() {
checkDiskCacheFor(fileName, finish);
mockTransferCallback = null;
});
}
@ -89,6 +57,39 @@ function test() {
}
function doTest(aIsPrivateMode, aWindow, aCallback) {
function contextMenuOpened(event) {
cache.clear();
aWindow.document.removeEventListener("popupshown", contextMenuOpened);
// Create the folder the image will be saved into.
var destDir = createTemporarySaveDirectory();
var destFile = destDir.clone();
MockFilePicker.displayDirectory = destDir;
MockFilePicker.showCallback = function(fp) {
fileName = fp.defaultString;
destFile.append (fileName);
MockFilePicker.returnFiles = [destFile];
MockFilePicker.filterIndex = 1; // kSaveAsType_URL
};
mockTransferCallback = onTransferComplete;
mockTransferRegisterer.register();
registerCleanupFunction(function () {
mockTransferRegisterer.unregister();
MockFilePicker.cleanup();
destDir.remove(true);
});
// Select "Save Image As" option from context menu
var saveVideoCommand = aWindow.document.getElementById("context-saveimage");
saveVideoCommand.doCommand();
event.target.hidePopup();
}
aWindow.gBrowser.addEventListener("pageshow", function pageShown(event) {
// If data: -url PAC file isn't loaded soon enough, we may get about:privatebrowsing loaded
if (event.target.location == "about:blank" ||
@ -98,14 +99,13 @@ function test() {
}
aWindow.gBrowser.removeEventListener("pageshow", pageShown);
executeSoon(function () {
aWindow.document.addEventListener("popupshown",
function(e) contextMenuOpened(aWindow, e), false);
waitForFocus(function () {
aWindow.document.addEventListener("popupshown", contextMenuOpened, false);
var img = aWindow.gBrowser.selectedBrowser.contentDocument.getElementById("img");
EventUtils.synthesizeMouseAtCenter(img,
{ type: "contextmenu", button: 2 },
aWindow.gBrowser.contentWindow);
});
}, aWindow.gBrowser.selectedBrowser.contentWindow);
});
}

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

@ -97,6 +97,7 @@ public:
// dst alpha is always 1.0. If this is never called, the context
// defaults to false (not opaque).
NS_IMETHOD SetIsOpaque(bool isOpaque) = 0;
virtual bool GetIsOpaque() = 0;
// Invalidate this context and release any held resources, in preperation
// for possibly reinitializing with SetDimensions/InitializeWithSurface.

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

@ -988,6 +988,10 @@ CanvasRenderingContext2D::SetIsOpaque(bool isOpaque)
ClearTarget();
}
if (mOpaque) {
EnsureTarget();
}
return NS_OK;
}
@ -1062,6 +1066,10 @@ CanvasRenderingContext2D::SetContextOptions(JSContext* aCx, JS::Handle<JS::Value
mForceSoftware = attributes.mWillReadFrequently;
}
if (!attributes.mAlpha) {
SetIsOpaque(true);
}
return NS_OK;
}
@ -3807,6 +3815,30 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx,
// inherited from Thebes canvas and is no longer true
uint8_t* dst = data + dstWriteRect.y * (aWidth * 4) + dstWriteRect.x * 4;
if (mOpaque) {
for (int32_t j = 0; j < dstWriteRect.height; ++j) {
for (int32_t i = 0; i < dstWriteRect.width; ++i) {
// XXX Is there some useful swizzle MMX we can use here?
#if MOZ_LITTLE_ENDIAN
uint8_t b = *src++;
uint8_t g = *src++;
uint8_t r = *src++;
src++;
#else
src++;
uint8_t r = *src++;
uint8_t g = *src++;
uint8_t b = *src++;
#endif
*dst++ = r;
*dst++ = g;
*dst++ = b;
*dst++ = 255;
}
src += srcStride - (dstWriteRect.width * 4);
dst += (aWidth * 4) - (dstWriteRect.width * 4);
}
} else
for (int32_t j = 0; j < dstWriteRect.height; ++j) {
for (int32_t i = 0; i < dstWriteRect.width; ++i) {
// XXX Is there some useful swizzle MMX we can use here?

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

@ -408,6 +408,7 @@ public:
{ EnsureTarget(); return mTarget->Snapshot(); }
NS_IMETHOD SetIsOpaque(bool isOpaque) MOZ_OVERRIDE;
bool GetIsOpaque() MOZ_OVERRIDE { return mOpaque; }
NS_IMETHOD Reset() MOZ_OVERRIDE;
already_AddRefed<CanvasLayer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
CanvasLayer *aOldLayer,

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

@ -178,6 +178,7 @@ public:
mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot() MOZ_OVERRIDE;
NS_IMETHOD SetIsOpaque(bool b) MOZ_OVERRIDE { return NS_OK; };
bool GetIsOpaque() MOZ_OVERRIDE { return false; }
NS_IMETHOD SetContextOptions(JSContext* aCx,
JS::Handle<JS::Value> aOptions) MOZ_OVERRIDE;

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

@ -21577,6 +21577,24 @@ function test_linedash() {
}
</script>
<p>Canvas test: test_opaque</p>
<canvas id="c688" width="150" height="50"></canvas>
<script type="text/javascript">
function test_opaque() {
var c = document.getElementById("c688");
var ctx = c.getContext("2d", {alpha: false});
ctx.fillStyle = "green";
ctx.fillRect(0,0,10,10);
ctx.fillStyle = "rgba(255,0,0,.5)";
ctx.fillRect(10,0,10,10);
isPixel(ctx, 20, 20, 0, 0, 0, 255, 0);
isPixel(ctx, 5, 5, 0, 128, 0, 255, 0);
isPixel(ctx, 15, 5, 128, 0, 0, 255, 0);
}
</script>
<script>
function asyncTestsDone() {
@ -24873,6 +24891,12 @@ function runTests() {
throw e;
ok(false, "unexpected exception thrown in: test_linedash");
}
try {
test_opaque();
} catch(e) {
throw e;
ok(false, "unexpected exception thrown in: test_opaque");
}
try {
// run this test last since it replaces the getContext method
test_type_replace();

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

@ -781,7 +781,7 @@ HTMLCanvasElement::UpdateContext(JSContext* aCx, JS::Handle<JS::Value> aNewConte
nsIntSize sz = GetWidthHeight();
nsresult rv = mCurrentContext->SetIsOpaque(GetIsOpaque());
nsresult rv = mCurrentContext->SetIsOpaque(HasAttr(kNameSpaceID_None, nsGkAtoms::moz_opaque));
if (NS_FAILED(rv)) {
mCurrentContext = nullptr;
mCurrentContextId.Truncate();
@ -903,6 +903,10 @@ HTMLCanvasElement::GetContextAtIndex(int32_t index)
bool
HTMLCanvasElement::GetIsOpaque()
{
if (mCurrentContext) {
return mCurrentContext->GetIsOpaque();
}
return HasAttr(kNameSpaceID_None, nsGkAtoms::moz_opaque);
}

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

@ -9,6 +9,7 @@
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.requestCompleteLog();
SimpleTest.waitForExplicitFinish();
// Copied from EventUtils.js, but we want *ToWindow methods.

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

@ -60,7 +60,7 @@ moz_gfx_memory_reset(MozGfxMemory *mem)
mem->image->Release();
ImageContainer* container = ((MozGfxMemoryAllocator*) mem->memory.allocator)->reader->GetImageContainer();
mem->image = reinterpret_cast<PlanarYCbCrImage*>(container->CreateImage(ImageFormat::PLANAR_YCBCR).get());
mem->image = reinterpret_cast<PlanarYCbCrImage*>(container->CreateImage(ImageFormat::PLANAR_YCBCR).take());
mem->data = mem->image->AllocateAndGetNewBuffer(mem->memory.size);
}

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

@ -410,7 +410,7 @@ DOMInterfaces = {
},
'FileRequest': {
'nativeType': 'mozilla::dom::file::DOMFileRequest',
'nativeType': 'mozilla::dom::file::FileRequest',
},
'FormData': [

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

@ -1,42 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DOMFileRequest.h"
#include "mozilla/dom/FileRequestBinding.h"
#include "LockedFile.h"
USING_FILE_NAMESPACE
DOMFileRequest::DOMFileRequest(nsPIDOMWindow* aWindow)
: FileRequest(aWindow)
{
}
// static
already_AddRefed<DOMFileRequest>
DOMFileRequest::Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile)
{
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
nsRefPtr<DOMFileRequest> request = new DOMFileRequest(aOwner);
request->mLockedFile = aLockedFile;
return request.forget();
}
/* virtual */ JSObject*
DOMFileRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
return FileRequestBinding::Wrap(aCx, aScope, this);
}
nsIDOMLockedFile*
DOMFileRequest::GetLockedFile() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mLockedFile;
}

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

@ -1,34 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_file_DOMFileRequest_h
#define mozilla_dom_file_DOMFileRequest_h
#include "FileRequest.h"
class nsIDOMLockedFile;
BEGIN_FILE_NAMESPACE
class DOMFileRequest : public FileRequest
{
public:
static already_AddRefed<DOMFileRequest>
Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile);
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
nsIDOMLockedFile* GetLockedFile() const;
IMPL_EVENT_HANDLER(progress)
protected:
DOMFileRequest(nsPIDOMWindow* aWindow);
};
END_FILE_NAMESPACE
#endif // mozilla_dom_file_DOMFileRequest_h

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

@ -164,7 +164,8 @@ FileHandle::GetFile(ErrorResult& aError)
return nullptr;
}
nsRefPtr<FileRequest> request = FileRequest::Create(GetOwner(), lockedFile);
nsRefPtr<FileRequest> request =
FileRequest::Create(GetOwner(), lockedFile, /* aWrapAsDOMRequest */ true);
nsRefPtr<MetadataParameters> params = new MetadataParameters(true, false);

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

@ -6,7 +6,7 @@
#include "FileRequest.h"
#include "DOMFileRequest.h"
#include "mozilla/dom/FileRequestBinding.h"
#include "nsCxPusher.h"
#include "nsEventDispatcher.h"
#include "nsError.h"
@ -18,7 +18,7 @@
USING_FILE_NAMESPACE
FileRequest::FileRequest(nsPIDOMWindow* aWindow)
: DOMRequest(aWindow)
: DOMRequest(aWindow), mWrapAsDOMRequest(false)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
}
@ -30,12 +30,14 @@ FileRequest::~FileRequest()
// static
already_AddRefed<FileRequest>
FileRequest::Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile)
FileRequest::Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile,
bool aWrapAsDOMRequest)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsRefPtr<FileRequest> request = new FileRequest(aOwner);
request->mLockedFile = aLockedFile;
request->mWrapAsDOMRequest = aWrapAsDOMRequest;
return request.forget();
}
@ -101,6 +103,23 @@ NS_INTERFACE_MAP_END_INHERITING(DOMRequest)
NS_IMPL_ADDREF_INHERITED(FileRequest, DOMRequest)
NS_IMPL_RELEASE_INHERITED(FileRequest, DOMRequest)
// virtual
JSObject*
FileRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
if (mWrapAsDOMRequest) {
return DOMRequest::WrapObject(aCx, aScope);
}
return FileRequestBinding::Wrap(aCx, aScope, this);
}
nsIDOMLockedFile*
FileRequest::GetLockedFile() const
{
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
return mLockedFile;
}
void
FileRequest::FireProgressEvent(uint64_t aLoaded, uint64_t aTotal)
{

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

@ -12,6 +12,8 @@
#include "DOMRequest.h"
class nsIDOMLockedFile;
BEGIN_FILE_NAMESPACE
class FileHelper;
@ -24,7 +26,8 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileRequest, DOMRequest)
static already_AddRefed<FileRequest>
Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile);
Create(nsPIDOMWindow* aOwner, LockedFile* aLockedFile,
bool aWrapAsDOMRequest);
// nsIDOMEventTarget
virtual nsresult
@ -39,6 +42,16 @@ public:
nsresult
NotifyHelperCompleted(FileHelper* aFileHelper);
// nsWrapperCache
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// WebIDL
nsIDOMLockedFile*
GetLockedFile() const;
IMPL_EVENT_HANDLER(progress)
protected:
FileRequest(nsPIDOMWindow* aWindow);
~FileRequest();
@ -47,6 +60,8 @@ protected:
FireProgressEvent(uint64_t aLoaded, uint64_t aTotal);
nsRefPtr<LockedFile> mLockedFile;
bool mWrapAsDOMRequest;
};
END_FILE_NAMESPACE

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

@ -22,9 +22,9 @@
#include "xpcpublic.h"
#include "AsyncHelper.h"
#include "DOMFileRequest.h"
#include "FileHandle.h"
#include "FileHelper.h"
#include "FileRequest.h"
#include "FileService.h"
#include "FileStreamWrappers.h"
#include "MemoryStreams.h"
@ -420,11 +420,11 @@ LockedFile::GetOrCreateStream(nsISupports** aStream)
return NS_OK;
}
already_AddRefed<DOMFileRequest>
already_AddRefed<FileRequest>
LockedFile::GenerateFileRequest()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return DOMFileRequest::Create(GetOwner(), this);
return FileRequest::Create(GetOwner(), this, /* aWrapAsDOMRequest */ false);
}
bool
@ -556,7 +556,7 @@ LockedFile::GetMetadata(JS::Handle<JS::Value> aParameters,
return NS_ERROR_TYPE_ERR;
}
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<MetadataHelper> helper =
new MetadataHelper(this, fileRequest, params);
@ -593,7 +593,7 @@ LockedFile::ReadAsArrayBuffer(uint64_t aSize,
return NS_OK;
}
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<ReadHelper> helper =
new ReadHelper(this, fileRequest, mLocation, aSize);
@ -635,7 +635,7 @@ LockedFile::ReadAsText(uint64_t aSize,
return NS_OK;
}
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<ReadTextHelper> helper =
new ReadTextHelper(this, fileRequest, mLocation, aSize, aEncoding);
@ -706,7 +706,7 @@ LockedFile::Truncate(uint64_t aSize,
return NS_OK;
}
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<TruncateHelper> helper =
new TruncateHelper(this, fileRequest, location);
@ -741,7 +741,7 @@ LockedFile::Flush(nsISupports** _retval)
return NS_OK;
}
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<FlushHelper> helper = new FlushHelper(this, fileRequest);
@ -863,7 +863,7 @@ LockedFile::WriteOrAppend(JS::Handle<JS::Value> aValue,
return NS_OK;
}
nsRefPtr<DOMFileRequest> fileRequest = GenerateFileRequest();
nsRefPtr<FileRequest> fileRequest = GenerateFileRequest();
uint64_t location = aAppend ? UINT64_MAX : mLocation;

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

@ -19,7 +19,6 @@ class nsIInputStream;
BEGIN_FILE_NAMESPACE
class DOMFileRequest;
class FileHandle;
class FileRequest;
class MetadataHelper;
@ -98,7 +97,7 @@ private:
void
OnRequestFinished();
inline already_AddRefed<DOMFileRequest>
already_AddRefed<FileRequest>
GenerateFileRequest();
nsresult

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

@ -22,11 +22,11 @@ EXPORTS.mozilla.dom.file += [
'ArchiveRequest.h',
'ArchiveZipEvent.h',
'ArchiveZipFile.h',
'DOMFileRequest.h',
'File.h',
'FileCommon.h',
'FileHandle.h',
'FileHelper.h',
'FileRequest.h',
'FileService.h',
'LockedFile.h',
]
@ -38,7 +38,6 @@ UNIFIED_SOURCES += [
'ArchiveZipEvent.cpp',
'ArchiveZipFile.cpp',
'AsyncHelper.cpp',
'DOMFileRequest.cpp',
'File.cpp',
'FileHandle.cpp',
'FileHelper.cpp',

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

@ -13,6 +13,8 @@ skip-if = buildapp == 'b2g'
[test_archivereader_zip_in_zip.html]
skip-if = buildapp == 'b2g'
[test_bug_793311.html]
[test_getFile.html]
skip-if = buildapp == 'b2g'
[test_getFileId.html]
[test_location.html]
skip-if = buildapp == 'b2g'

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

@ -0,0 +1,43 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>File Handle 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;version=1.7">
function testSteps()
{
for each (let fileStorage in fileStorages) {
let request = getFileHandle(fileStorage.key, "test.txt");
request.onerror = errorHandler;
request.onsuccess = grabEventAndContinueHandler;
let event = yield undefined;
let fileHandle = event.target.result;
fileHandle.onerror = errorHandler;
request = fileHandle.getFile();
ok(request instanceof DOMRequest, "Correct interface");
ok(!(request instanceof FileRequest), "Correct interface");
ok(!('lockedFile' in request), "Property should not exist");
ok(request.lockedFile === undefined, "Property should not exist");
ok(!('onprogress' in request), "Property should not exist");
ok(request.onprogress === undefined, "Property should not exist");
}
finishTest();
yield undefined;
}
</script>
<script type="text/javascript;version=1.7" src="helpers.js"></script>
</head>
<body onload="runTest();"></body>
</html>

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

@ -16,6 +16,8 @@ enum CanvasWindingRule { "nonzero", "evenodd" };
dictionary ContextAttributes2D {
// whether or not we're planning to do a lot of readback operations
boolean willReadFrequently = false;
// signal if the canvas contains an alpha channel
boolean alpha = true;
};
dictionary HitRegionOptions {

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

@ -309,9 +309,9 @@ StructTypeRepresentation::init(JSContext *cx,
// We compute alignment into the field `align_` directly in the
// loop below, but not `size_` because we have to very careful
// about overflow. For now, we always use a uint32_t for
// about overflow. For now, we always use a int32_t for
// consistency across build environments.
uint32_t totalSize = 0;
int32_t totalSize = 0;
// These will be adjusted in the loop below:
alignment_ = 1;
@ -324,7 +324,7 @@ StructTypeRepresentation::init(JSContext *cx,
if (fieldTypeRepr->opaque())
opaque_ = true;
uint32_t alignedSize = alignTo(totalSize, fieldTypeRepr->alignment());
int32_t alignedSize = alignTo(totalSize, fieldTypeRepr->alignment());
if (alignedSize < totalSize) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
JSMSG_TYPEDOBJECT_TOO_BIG);
@ -335,7 +335,7 @@ StructTypeRepresentation::init(JSContext *cx,
fieldTypeRepr, alignedSize);
alignment_ = js::Max(alignment_, fieldTypeRepr->alignment());
uint32_t incrementedSize = alignedSize + fieldTypeRepr->size();
int32_t incrementedSize = alignedSize + fieldTypeRepr->size();
if (incrementedSize < alignedSize) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
JSMSG_TYPEDOBJECT_TOO_BIG);
@ -345,7 +345,7 @@ StructTypeRepresentation::init(JSContext *cx,
totalSize = incrementedSize;
}
uint32_t alignedSize = alignTo(totalSize, alignment_);
int32_t alignedSize = alignTo(totalSize, alignment_);
if (alignedSize < totalSize) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
JSMSG_TYPEDOBJECT_TOO_BIG);

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

@ -2301,6 +2301,12 @@ TypedObject::constructSized(JSContext *cx, unsigned int argc, Value *vp)
Rooted<ArrayBufferObject*> buffer(cx);
buffer = &args[0].toObject().as<ArrayBufferObject>();
if (buffer->isNeutered()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage,
nullptr, JSMSG_TYPEDOBJECT_BAD_ARGS);
return false;
}
int32_t offset;
if (args.length() >= 2 && !args[1].isUndefined()) {
if (!args[1].isInt32()) {
@ -2407,6 +2413,12 @@ TypedObject::constructUnsized(JSContext *cx, unsigned int argc, Value *vp)
Rooted<ArrayBufferObject*> buffer(cx);
buffer = &args[0].toObject().as<ArrayBufferObject>();
if (buffer->isNeutered()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage,
nullptr, JSMSG_TYPEDOBJECT_BAD_ARGS);
return false;
}
int32_t offset;
if (args.length() >= 2 && !args[1].isUndefined()) {
if (!args[1].isInt32()) {

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

@ -0,0 +1,23 @@
// Bug 976697. Check for various quirks when instantiating a typed
// object atop an already neutered buffer.
if (typeof TypedObject === "undefined")
quit();
load(libdir + "asserts.js")
var {StructType, uint32, Object, Any, storage, objectType} = TypedObject;
function main() { // once a C programmer, always a C programmer.
var Uints = uint32.array();
var Unit = new StructType({}); // Empty struct type
var buffer = new ArrayBuffer(0); // Empty buffer
var p = new Unit(buffer); // OK
neuter(buffer);
assertThrowsInstanceOf(() => new Unit(buffer), TypeError,
"Able to instantiate atop neutered buffer");
assertThrowsInstanceOf(() => new Uints(buffer, 0), TypeError,
"Able to instantiate atop neutered buffer");
}
main();

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

@ -0,0 +1,10 @@
// |jit-test| error:Error
// Test that we don't permit structs whose fields exceed 32 bits.
if (!this.hasOwnProperty("TypedObject"))
throw new Error();
var Vec3u16Type = TypedObject.uint16.array((1073741823));
var PairVec3u16Type = new TypedObject.StructType({ fst: Vec3u16Type, snd: Vec3u16Type });
new PairVec3u16Type();

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

@ -0,0 +1,13 @@
// Test that instantiating a typed array on top of a neutered buffer
// doesn't trip any asserts.
//
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/
if (!this.hasOwnProperty("TypedObject"))
quit();
x = ArrayBuffer();
neuter(x);
Uint32Array(x);
gc();

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

@ -1807,11 +1807,6 @@ Assembler::placeConstantPoolBarrier(int offset)
// this is still an active path, however, we do not hit it in the test
// suite at all.
MOZ_ASSUME_UNREACHABLE("ARMAssembler holdover");
#if 0
offset = (offset - sizeof(ARMWord)) >> 2;
ASSERT((offset <= BOFFSET_MAX && offset >= BOFFSET_MIN));
return AL | B | (offset & BRANCH_MASK);
#endif
}
// Control flow stuff:

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

@ -13,54 +13,6 @@
using namespace js;
using namespace js::jit;
#if 0
// no clue what these asserts should be.
JS_STATIC_ASSERT(sizeof(BailoutStack) ==
sizeof(uintptr_t) +
sizeof(double) * 8 +
sizeof(uintptr_t) * 8 +
sizeof(uintptr_t));
JS_STATIC_ASSERT(sizeof(ExtendedBailoutStack) ==
sizeof(BailoutStack) +
sizeof(uintptr_t));
#endif
#if 0
BailoutEnvironment::BailoutEnvironment(JitCompartment *ion, void **sp)
: sp_(sp)
{
bailout_ = reinterpret_cast<ExtendedBailoutStack *>(sp);
if (bailout_->frameClass() != FrameSizeClass::None()) {
frameSize_ = bailout_->frameSize();
frame_ = &sp_[sizeof(BailoutStack) / sizeof(void *)];
// Compute the bailout ID.
JitCode *code = ion->getBailoutTable(bailout_->frameClass());
uintptr_t tableOffset = bailout_->tableOffset();
uintptr_t tableStart = reinterpret_cast<uintptr_t>(code->raw());
JS_ASSERT(tableOffset >= tableStart &&
tableOffset < tableStart + code->instructionsSize());
JS_ASSERT((tableOffset - tableStart) % BAILOUT_TABLE_ENTRY_SIZE == 0);
bailoutId_ = ((tableOffset - tableStart) / BAILOUT_TABLE_ENTRY_SIZE) - 1;
JS_ASSERT(bailoutId_ < BAILOUT_TABLE_SIZE);
} else {
frameSize_ = bailout_->frameSize();
frame_ = &sp_[sizeof(ExtendedBailoutStack) / sizeof(void *)];
}
}
IonFramePrefix *
BailoutEnvironment::top() const
{
return (IonFramePrefix *)&frame_[frameSize_ / sizeof(void *)];
}
#endif
namespace js {
namespace jit {

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

@ -242,23 +242,8 @@ CodeGeneratorARM::bailoutFrom(Label *label, LSnapshot *snapshot)
// isn't properly aligned to the static frame size.
JS_ASSERT_IF(frameClass_ != FrameSizeClass::None(),
frameClass_.frameSize() == masm.framePushed());
// This involves retargeting a label, which I've declared is always going
// to be a pc-relative branch to an absolute address!
// With no assurance that this is going to be a local branch, I am wary to
// implement this. Moreover, If it isn't a local branch, it will be large
// and possibly slow. I believe that the correct way to handle this is to
// subclass label into a fatlabel, where we generate enough room for a load
// before the branch
#if 0
if (assignBailoutId(snapshot)) {
uint8_t *code = deoptTable_->raw() + snapshot->bailoutId() * BAILOUT_TABLE_ENTRY_SIZE;
masm.retarget(label, code, Relocation::HARDCODED);
return true;
}
#endif
// We could not use a jump table, either because all bailout IDs were
// reserved, or a jump table is not optimal for this frame size or
// platform. Whatever, we will generate a lazy bailout.
// On ARM we don't use a bailout table.
OutOfLineBailout *ool = new(alloc()) OutOfLineBailout(snapshot, masm.framePushed());
if (!addOutOfLineCode(ool)) {
return false;
@ -1661,14 +1646,6 @@ CodeGeneratorARM::visitNotD(LNotD *ins)
masm.ma_mov(Imm32(0), dest);
masm.ma_mov(Imm32(1), dest, NoSetCond, Assembler::Equal);
masm.ma_mov(Imm32(1), dest, NoSetCond, Assembler::Overflow);
#if 0
masm.as_vmrs(ToRegister(dest));
// Mask out just the two bits we care about. If neither bit is set,
// the dest is already zero
masm.ma_and(Imm32(0x50000000), dest, dest, Assembler::SetCond);
// If it is non-zero, then force it to be 1.
masm.ma_mov(Imm32(1), dest, NoSetCond, Assembler::NotEqual);
#endif
}
return true;
}
@ -1698,14 +1675,6 @@ CodeGeneratorARM::visitNotF(LNotF *ins)
masm.ma_mov(Imm32(0), dest);
masm.ma_mov(Imm32(1), dest, NoSetCond, Assembler::Equal);
masm.ma_mov(Imm32(1), dest, NoSetCond, Assembler::Overflow);
#if 0
masm.as_vmrs(ToRegister(dest));
// Mask out just the two bits we care about. If neither bit is set,
// the dest is already zero
masm.ma_and(Imm32(0x50000000), dest, dest, Assembler::SetCond);
// If it is non-zero, then force it to be 1.
masm.ma_mov(Imm32(1), dest, NoSetCond, Assembler::NotEqual);
#endif
}
return true;
}

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

@ -148,18 +148,6 @@ JitRuntime::generateEnterJIT(JSContext *cx, EnterJitType type)
masm.loadPtr(slot_vp, r10);
masm.unboxInt32(Address(r10, 0), r10);
#if 0
// This is in case we want to go back to using frames that
// aren't 8 byte alinged
// there are r1 2-word arguments to the js code
// we want 2 word alignment, so this shouldn't matter.
// After the arguments have been pushed, we want to push an additional 3 words of
// data, so in all, we want to decrease sp by 4 if it is currently aligned to
// 8, and not touch it otherwise
aasm->as_sub(sp, sp, Imm8(4));
aasm->as_orr(sp, sp, Imm8(4));
#endif
// Subtract off the size of the arguments from the stack pointer, store elsewhere
aasm->as_sub(r4, sp, O2RegImmShift(r1, LSL, 3)); //r4 = sp - argc*8
// Get the final position of the stack pointer into the stack pointer

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

@ -303,6 +303,7 @@ static ObjectElements *
AllocateArrayBufferContents(JSContext *maybecx, uint32_t nbytes, void *oldptr = nullptr)
{
uint32_t size = nbytes + sizeof(ObjectElements);
JS_ASSERT(size > nbytes); // be wary of rollover
ObjectElements *newheader;
// if oldptr is given, then we need to do a realloc

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

@ -302,7 +302,14 @@ InitArrayBufferViewDataPointer(ArrayBufferViewObject *obj, ArrayBufferObject *bu
* private data rather than a slot to avoid alignment restrictions
* on private Values.
*/
obj->initPrivate(buffer->dataPointer() + byteOffset);
if (buffer->isNeutered()) {
JS_ASSERT(byteOffset == 0);
obj->initPrivate(nullptr);
} else {
obj->initPrivate(buffer->dataPointer() + byteOffset);
}
PostBarrierTypedArrayObject(obj);
}

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

@ -362,7 +362,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject
uint32_t bufferByteLength = buffer->byteLength();
uint32_t arrayByteLength = obj->byteLength();
uint32_t arrayByteOffset = obj->byteOffset();
JS_ASSERT(buffer->dataPointer() <= obj->viewData());
JS_ASSERT_IF(!buffer->isNeutered(), buffer->dataPointer() <= obj->viewData());
JS_ASSERT(bufferByteLength - arrayByteOffset >= arrayByteLength);
JS_ASSERT(arrayByteOffset <= bufferByteLength);

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

@ -24,6 +24,8 @@ const Ci = SpecialPowers.Ci;
const Cc = SpecialPowers.Cc;
const Cr = SpecialPowers.Cr;
Components.utils.import("resource://gre/modules/Services.jsm");
var testpath = "/tests/toolkit/components/passwordmgr/test/";
var prefix = "http://test2.example.com" + testpath;
var subtests = [
@ -191,24 +193,35 @@ var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
var contentPage = "http://mochi.test:8888/tests/toolkit/components/passwordmgr/test/privbrowsing_perwindowpb_iframe.html";
var testWindows = [];
function whenDelayedStartupFinished(aWindow, aCallback) {
Services.obs.addObserver(function observer(aSubject, aTopic) {
if (aWindow == aSubject) {
Services.obs.removeObserver(observer, aTopic);
setTimeout(aCallback, 0);
}
}, "browser-delayed-startup-finished", false);
}
function testOnWindow(aIsPrivate, aCallback) {
var win = mainWindow.OpenBrowserWindow({private: aIsPrivate});
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad, false);
win.addEventListener("DOMContentLoaded", function onInnerLoad() {
if (win.content.location.href != contentPage) {
win.gBrowser.loadURI(contentPage);
return;
}
win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
whenDelayedStartupFinished(win, function() {
win.addEventListener("DOMContentLoaded", function onInnerLoad() {
if (win.content.location.href != contentPage) {
win.gBrowser.loadURI(contentPage);
return;
}
win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
win.content.addEventListener('load', function innerLoad2() {
win.content.removeEventListener('load', innerLoad2, false);
testWindows.push(win);
SimpleTest.executeSoon(function() { aCallback(win); });
}, false, true);
}, true);
SimpleTest.executeSoon(function() { win.gBrowser.loadURI(contentPage); });
win.content.addEventListener('load', function innerLoad2() {
win.content.removeEventListener('load', innerLoad2, false);
testWindows.push(win);
SimpleTest.executeSoon(function() { aCallback(win); });
}, false, true);
}, true);
SimpleTest.executeSoon(function() { win.gBrowser.loadURI(contentPage); });
});
}, true);
}

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

@ -24,6 +24,7 @@
<![CDATA[
SimpleTest.waitForExplicitFinish();
SimpleTest.requestCompleteLog();
var expected = [ "one", "_extra2", "tab", "one", "tabbutton2", "tabbutton", "two", "textbox-yes", "one" ];
// non-Mac will always focus the default button if any of the dialog buttons
@ -39,13 +40,16 @@ function startTest()
var testButton = document.getElementById("test");
synthesizeKey("VK_TAB", { });
fullKeyboardAccess = (document.activeElement == testButton);
info("We " + (fullKeyboardAccess ? "have" : "don't have") + " full keyboard access");
runTest();
}
function runTest()
{
step++;
info("runTest(), step = " + step + ", expected = " + expected[step - 1]);
if (step > expected.length || (!fullKeyboardAccess && step == 2)) {
info("finishing");
SimpleTest.finish();
return;
}
@ -55,11 +59,14 @@ function runTest()
function checkDialogFocus(event)
{
info("checkDialogFocus()");
// if full keyboard access is not on, just skip the tests
var match = false;
if (fullKeyboardAccess) {
if (!(event.target instanceof Element))
if (!(event.target instanceof Element)) {
info("target not an Element");
return;
}
if (expectedFocus == "textbox-yes")
match = (win.document.activeElement == win.document.getElementById(expectedFocus).inputField);
@ -67,11 +74,13 @@ function runTest()
match = (win.document.activeElement.dlgType == expectedFocus.substring(1));
else
match = (win.document.activeElement.id == expectedFocus);
info("match = " + match);
if (!match)
return;
}
else {
match = (win.document.activeElement == win.document.documentElement);
info("match = " + match);
}
win.removeEventListener("focus", checkDialogFocus, true);