зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1079844 - Rename JS_IsNeuteredArrayBufferObject to JS_IsDetachedArrayBufferObject. r=till
--HG-- extra : rebase_source : 31cfdce35e6e8dc8d212391ae485aa8fec6ead5b
This commit is contained in:
Родитель
c004cbcf79
Коммит
e42d55ea6e
|
@ -1212,11 +1212,11 @@ EventRunnable::PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
|||
if (obj && JS_IsArrayBufferObject(obj)) {
|
||||
// Use cached response if the arraybuffer has been transfered.
|
||||
if (mProxy->mArrayBufferResponseWasTransferred) {
|
||||
MOZ_ASSERT(JS_IsNeuteredArrayBufferObject(obj));
|
||||
MOZ_ASSERT(JS_IsDetachedArrayBufferObject(obj));
|
||||
mUseCachedArrayBufferResponse = true;
|
||||
doClone = false;
|
||||
} else {
|
||||
MOZ_ASSERT(!JS_IsNeuteredArrayBufferObject(obj));
|
||||
MOZ_ASSERT(!JS_IsDetachedArrayBufferObject(obj));
|
||||
JS::AutoValueArray<1> argv(aCx);
|
||||
argv[0].set(response);
|
||||
obj = JS_NewArrayObject(aCx, argv);
|
||||
|
|
|
@ -58,20 +58,7 @@ BEGIN_TEST(testArrayBuffer_bug720949_steal)
|
|||
void* contents = JS_StealArrayBufferContents(cx, obj);
|
||||
CHECK(contents != nullptr);
|
||||
|
||||
// Check that the original ArrayBuffer is neutered
|
||||
CHECK_EQUAL(JS_GetArrayBufferByteLength(obj), 0u);
|
||||
CHECK(JS_GetProperty(cx, obj, "byteLength", &v));
|
||||
CHECK(v.isInt32(0));
|
||||
CHECK(JS_GetProperty(cx, view, "byteLength", &v));
|
||||
CHECK(v.isInt32(0));
|
||||
CHECK(JS_GetProperty(cx, view, "byteOffset", &v));
|
||||
CHECK(v.isInt32(0));
|
||||
CHECK(JS_GetProperty(cx, view, "length", &v));
|
||||
CHECK(v.isInt32(0));
|
||||
CHECK_EQUAL(JS_GetArrayBufferByteLength(obj), 0u);
|
||||
v.setUndefined();
|
||||
JS_GetElement(cx, obj, 0, &v);
|
||||
CHECK(v.isUndefined());
|
||||
CHECK(JS_IsDetachedArrayBufferObject(obj));
|
||||
|
||||
// Transfer to a new ArrayBuffer
|
||||
JS::RootedObject dst(cx, JS_NewArrayBufferWithContents(cx, size, contents));
|
||||
|
@ -120,7 +107,7 @@ BEGIN_TEST(testArrayBuffer_bug720949_viewList)
|
|||
JS_free(nullptr, contents);
|
||||
GC(cx);
|
||||
CHECK(isNeutered(view));
|
||||
CHECK(isNeutered(buffer));
|
||||
CHECK(JS_IsDetachedArrayBufferObject(buffer));
|
||||
view = nullptr;
|
||||
GC(cx);
|
||||
buffer = nullptr;
|
||||
|
@ -146,7 +133,7 @@ BEGIN_TEST(testArrayBuffer_bug720949_viewList)
|
|||
|
||||
CHECK(isNeutered(view1));
|
||||
CHECK(isNeutered(view2));
|
||||
CHECK(isNeutered(buffer));
|
||||
CHECK(JS_IsDetachedArrayBufferObject(buffer));
|
||||
|
||||
view1 = nullptr;
|
||||
GC(cx);
|
||||
|
|
|
@ -117,7 +117,7 @@ bool TestDetachObject()
|
|||
JS::RootedObject obj(cx, CreateNewObject(8, 12));
|
||||
CHECK(obj);
|
||||
JS_DetachArrayBuffer(cx, obj, ChangeData);
|
||||
CHECK(isNeutered(obj));
|
||||
CHECK(JS_IsDetachedArrayBufferObject(obj));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ bool TestStealContents()
|
|||
void* contents = JS_StealArrayBufferContents(cx, obj);
|
||||
CHECK(contents);
|
||||
CHECK(memcmp(contents, test_data + 8, 12) == 0);
|
||||
CHECK(isNeutered(obj));
|
||||
CHECK(JS_IsDetachedArrayBufferObject(obj));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -168,17 +168,11 @@ bool TestTransferObject()
|
|||
CHECK(cloned_buffer.read(cx, &v2, nullptr, nullptr));
|
||||
JS::RootedObject obj2(cx, v2.toObjectOrNull());
|
||||
CHECK(VerifyObject(obj2, 8, 12, true));
|
||||
CHECK(isNeutered(obj1));
|
||||
CHECK(JS_IsDetachedArrayBufferObject(obj1));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isNeutered(JS::HandleObject obj)
|
||||
{
|
||||
JS::RootedValue v(cx);
|
||||
return JS_GetProperty(cx, obj, "byteLength", &v) && v.toInt32() == 0;
|
||||
}
|
||||
|
||||
static void GC(JSContext* cx)
|
||||
{
|
||||
JS_GC(JS_GetRuntime(cx));
|
||||
|
|
|
@ -1899,7 +1899,7 @@ JS_GetSharedArrayBufferByteLength(JSObject* obj);
|
|||
|
||||
/**
|
||||
* Return true if the arrayBuffer contains any data. This will return false for
|
||||
* ArrayBuffer.prototype and neutered ArrayBuffers.
|
||||
* ArrayBuffer.prototype and detached ArrayBuffers.
|
||||
*
|
||||
* |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known
|
||||
* that it would pass such a test: it is an ArrayBuffer or a wrapper of an
|
||||
|
@ -2020,9 +2020,8 @@ extern JS_FRIEND_API(void*)
|
|||
JS_GetArrayBufferViewData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&);
|
||||
|
||||
/**
|
||||
* Return the ArrayBuffer or SharedArrayBuffer underlying an
|
||||
* ArrayBufferView. If the buffer has been neutered, this will still
|
||||
* return the neutered buffer. |obj| must be an object that would
|
||||
* Return the ArrayBuffer or SharedArrayBuffer underlying an ArrayBufferView.
|
||||
* This may return a detached buffer. |obj| must be an object that would
|
||||
* return true for JS_IsArrayBufferViewObject().
|
||||
*/
|
||||
extern JS_FRIEND_API(JSObject*)
|
||||
|
@ -2049,12 +2048,12 @@ JS_DetachArrayBuffer(JSContext* cx, JS::HandleObject obj,
|
|||
DetachDataDisposition changeData);
|
||||
|
||||
/**
|
||||
* Check whether the obj is ArrayBufferObject and neutered. Note that this
|
||||
* may return false if a security wrapper is encountered that denies the
|
||||
* Check whether the obj is a detached ArrayBufferObject. Note that this may
|
||||
* return false if a security wrapper is encountered that denies the
|
||||
* unwrapping.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
JS_IsNeuteredArrayBufferObject(JSObject* obj);
|
||||
JS_IsDetachedArrayBufferObject(JSObject* obj);
|
||||
|
||||
/**
|
||||
* Check whether obj supports JS_GetDataView* APIs.
|
||||
|
|
|
@ -1155,7 +1155,7 @@ JS_DetachArrayBuffer(JSContext* cx, HandleObject obj,
|
|||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS_IsNeuteredArrayBufferObject(JSObject* obj)
|
||||
JS_IsDetachedArrayBufferObject(JSObject* obj)
|
||||
{
|
||||
obj = CheckedUnwrap(obj);
|
||||
if (!obj)
|
||||
|
|
Загрузка…
Ссылка в новой задаче