mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Backout f142f32a98a3 (Bug 775317) and ef14686c31d0 (Bug 761278). r=bustage
This commit is contained in:
parent
0bb06f3e45
commit
380d2ba82c
@ -48,3 +48,4 @@ DEPRECATED_OPERATION(DOMExceptionCode)
|
||||
DEPRECATED_OPERATION(NoExposedProps)
|
||||
DEPRECATED_OPERATION(MutationEvent)
|
||||
DEPRECATED_OPERATION(MozSlice)
|
||||
DEPRECATED_OPERATION(Onuploadprogress)
|
||||
|
@ -395,8 +395,22 @@ interface nsIXHRSendable : nsISupports {
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
[deprecated, scriptable, uuid(8ae70a39-edf1-40b4-a992-472d23421c25)]
|
||||
[deprecated, scriptable, uuid(423fdd3d-41c9-4149-8fe5-b14a1d3912a0)]
|
||||
interface nsIJSXMLHttpRequest : nsISupports {
|
||||
/**
|
||||
* Meant to be a script-only mechanism for setting an upload progress event
|
||||
* listener.
|
||||
* This attribute should not be used from native code!!
|
||||
* This event listener may be called multiple times during the upload..
|
||||
*
|
||||
* After the initial response, all event listeners will be cleared.
|
||||
* // XXXbz what does that mean, exactly?
|
||||
*
|
||||
* This event listener must be set BEFORE calling open().
|
||||
*
|
||||
* Mozilla only.
|
||||
*/
|
||||
attribute nsIDOMEventListener onuploadprogress;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
@ -90,6 +90,7 @@ using namespace mozilla::dom;
|
||||
#define TIMEOUT_STR "timeout"
|
||||
#define LOADSTART_STR "loadstart"
|
||||
#define PROGRESS_STR "progress"
|
||||
#define UPLOADPROGRESS_STR "uploadprogress"
|
||||
#define READYSTATE_STR "readystatechange"
|
||||
#define LOADEND_STR "loadend"
|
||||
|
||||
@ -618,6 +619,7 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsXMLHttpRequest)
|
||||
NS_UNMARK_LISTENER_WRAPPER(LoadStart)
|
||||
NS_UNMARK_LISTENER_WRAPPER(Progress)
|
||||
NS_UNMARK_LISTENER_WRAPPER(Loadend)
|
||||
NS_UNMARK_LISTENER_WRAPPER(UploadProgress)
|
||||
NS_UNMARK_LISTENER_WRAPPER(Readystatechange)
|
||||
}
|
||||
if (!isBlack && tmp->PreservingWrapper()) {
|
||||
@ -643,6 +645,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLHttpRequest,
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mResponseXML)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCORSPreflightChannel)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnUploadProgressListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnReadystatechangeListener)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mXMLParserStreamListener)
|
||||
@ -664,6 +667,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest,
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mResponseXML)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCORSPreflightChannel)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnUploadProgressListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnReadystatechangeListener)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mXMLParserStreamListener)
|
||||
@ -704,6 +708,7 @@ void
|
||||
nsXMLHttpRequest::DisconnectFromOwner()
|
||||
{
|
||||
nsXHREventTarget::DisconnectFromOwner();
|
||||
NS_DISCONNECT_EVENT_HANDLER(UploadProgress)
|
||||
NS_DISCONNECT_EVENT_HANDLER(Readystatechange)
|
||||
Abort();
|
||||
}
|
||||
@ -725,6 +730,23 @@ nsXMLHttpRequest::SetOnreadystatechange(nsIDOMEventListener * aOnreadystatechang
|
||||
aOnreadystatechange);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetOnuploadprogress(nsIDOMEventListener * *aOnuploadprogress)
|
||||
{
|
||||
return
|
||||
nsXHREventTarget::GetInnerEventListener(mOnUploadProgressListener,
|
||||
aOnuploadprogress);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::SetOnuploadprogress(nsIDOMEventListener * aOnuploadprogress)
|
||||
{
|
||||
return
|
||||
nsXHREventTarget::RemoveAddEventListener(NS_LITERAL_STRING(UPLOADPROGRESS_STR),
|
||||
mOnUploadProgressListener,
|
||||
aOnuploadprogress);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIChannel channel; */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetChannel(nsIChannel **aChannel)
|
||||
@ -1633,7 +1655,8 @@ nsXMLHttpRequest::DispatchProgressEvent(nsDOMEventTargetHelper* aTarget,
|
||||
NS_ASSERTION(!aType.IsEmpty(), "missing event type");
|
||||
|
||||
if (NS_FAILED(CheckInnerWindowCorrectness()) ||
|
||||
(!AllowUploadProgress() && aTarget == mUpload)) {
|
||||
(!AllowUploadProgress() &&
|
||||
(aTarget == mUpload || aType.EqualsLiteral(UPLOADPROGRESS_STR)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1729,6 +1752,7 @@ nsXMLHttpRequest::CheckChannelForCrossSiteRequest(nsIChannel* aChannel)
|
||||
nsCAutoString method;
|
||||
httpChannel->GetRequestMethod(method);
|
||||
if (!mCORSUnsafeHeaders.IsEmpty() ||
|
||||
HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR)) ||
|
||||
(mUpload && mUpload->HasListeners()) ||
|
||||
(!method.LowerCaseEqualsLiteral("get") &&
|
||||
!method.LowerCaseEqualsLiteral("post") &&
|
||||
@ -2796,6 +2820,7 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
|
||||
// a progress event handler we must load with nsIRequest::LOAD_NORMAL or
|
||||
// necko won't generate any progress notifications.
|
||||
if (HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)) ||
|
||||
HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR)) ||
|
||||
(mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)))) {
|
||||
nsLoadFlags loadFlags;
|
||||
mChannel->GetLoadFlags(&loadFlags);
|
||||
@ -3154,7 +3179,9 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
|
||||
// can run script that would try to restart this request, and that could end
|
||||
// up doing our AsyncOpen on a null channel if the reentered AsyncOpen fails.
|
||||
ChangeState(XML_HTTP_REQUEST_SENT);
|
||||
if (mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR))) {
|
||||
if ((!mUploadComplete &&
|
||||
HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR))) ||
|
||||
(mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)))) {
|
||||
StartProgressEventTimer();
|
||||
}
|
||||
DispatchProgressEvent(this, NS_LITERAL_STRING(LOADSTART_STR), false,
|
||||
@ -3695,6 +3722,10 @@ nsXMLHttpRequest::MaybeDispatchProgressEvents(bool aFinalProgress)
|
||||
mUploadProgressMax = mUploadProgress;
|
||||
mUploadLengthComputable = true;
|
||||
}
|
||||
DispatchProgressEvent(this, NS_LITERAL_STRING(UPLOADPROGRESS_STR),
|
||||
true, mUploadLengthComputable, mUploadTransferred,
|
||||
mUploadTotal, mUploadProgress,
|
||||
mUploadProgressMax);
|
||||
if (mUpload && !mUploadComplete) {
|
||||
DispatchProgressEvent(mUpload, NS_LITERAL_STRING(PROGRESS_STR),
|
||||
true, mUploadLengthComputable, mUploadTransferred,
|
||||
|
@ -217,6 +217,10 @@ public:
|
||||
// nsIXMLHttpRequest
|
||||
NS_DECL_NSIXMLHTTPREQUEST
|
||||
|
||||
// nsIJSXMLHttpRequest
|
||||
NS_IMETHOD GetOnuploadprogress(nsIDOMEventListener** aOnuploadprogress);
|
||||
NS_IMETHOD SetOnuploadprogress(nsIDOMEventListener* aOnuploadprogress);
|
||||
|
||||
NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::)
|
||||
|
||||
// nsIStreamListener
|
||||
@ -249,6 +253,24 @@ public:
|
||||
|
||||
// event handler
|
||||
IMPL_EVENT_HANDLER(readystatechange, Readystatechange)
|
||||
JSObject* GetOnuploadprogress(JSContext* /* unused */)
|
||||
{
|
||||
nsIDocument* doc = GetOwner() ? GetOwner()->GetExtantDoc() : NULL;
|
||||
if (doc) {
|
||||
doc->WarnOnceAbout(nsIDocument::eOnuploadprogress);
|
||||
}
|
||||
return GetListenerAsJSObject(mOnUploadProgressListener);
|
||||
}
|
||||
void SetOnuploadprogress(JSContext* aCx, JSObject* aCallback,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsIDocument* doc = GetOwner() ? GetOwner()->GetExtantDoc() : NULL;
|
||||
if (doc) {
|
||||
doc->WarnOnceAbout(nsIDocument::eOnuploadprogress);
|
||||
}
|
||||
aRv = SetJSObjectListener(aCx, NS_LITERAL_STRING("uploadprogress"),
|
||||
mOnUploadProgressListener, aCallback);
|
||||
}
|
||||
|
||||
// states
|
||||
uint16_t GetReadyState();
|
||||
@ -555,6 +577,7 @@ protected:
|
||||
nsCOMPtr<nsIChannel> mCORSPreflightChannel;
|
||||
nsTArray<nsCString> mCORSUnsafeHeaders;
|
||||
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnUploadProgressListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnReadystatechangeListener;
|
||||
|
||||
nsCOMPtr<nsIStreamListener> mXMLParserStreamListener;
|
||||
|
@ -37,9 +37,16 @@ window.addEventListener("message", function(e) {
|
||||
res.progressEvents++;
|
||||
}, false);
|
||||
if (req.uploadProgress) {
|
||||
xhr.upload.addEventListener(req.uploadProgress, function(e) {
|
||||
res.progressEvents++;
|
||||
}, false);
|
||||
if (req.uploadProgress == "uploadProgress") {
|
||||
xhr.addEventListener("uploadProgress", function(e) {
|
||||
res.progressEvents++;
|
||||
}, false);
|
||||
}
|
||||
else {
|
||||
xhr.upload.addEventListener(req.uploadProgress, function(e) {
|
||||
res.progressEvents++;
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
xhr.onerror = function(e) {
|
||||
res.didFail = true;
|
||||
|
@ -26,9 +26,16 @@ window.addEventListener("message", function(e) {\n\
|
||||
res.progressEvents++;\n\
|
||||
}, false);\n\
|
||||
if (req.uploadProgress) {\n\
|
||||
xhr.upload.addEventListener(req.uploadProgress, function(e) {\n\
|
||||
res.progressEvents++;\n\
|
||||
}, false);\n\
|
||||
if (req.uploadProgress == "uploadProgress") {\n\
|
||||
xhr.addEventListener("uploadProgress", function(e) {\n\
|
||||
res.progressEvents++;\n\
|
||||
}, false);\n\
|
||||
}\n\
|
||||
else {\n\
|
||||
xhr.upload.addEventListener(req.uploadProgress, function(e) {\n\
|
||||
res.progressEvents++;\n\
|
||||
}, false);\n\
|
||||
}\n\
|
||||
}\n\
|
||||
xhr.onerror = function(e) {\n\
|
||||
res.didFail = true;\n\
|
||||
|
@ -449,12 +449,25 @@ function runTest() {
|
||||
},
|
||||
|
||||
// Progress events
|
||||
{ pass: 1,
|
||||
method: "POST",
|
||||
body: "hi there",
|
||||
headers: { "Content-Type": "text/plain" },
|
||||
uploadProgress: "uploadprogress",
|
||||
},
|
||||
{ pass: 1,
|
||||
method: "POST",
|
||||
body: "hi there",
|
||||
headers: { "Content-Type": "text/plain" },
|
||||
uploadProgress: "progress",
|
||||
},
|
||||
{ pass: 0,
|
||||
method: "POST",
|
||||
body: "hi there",
|
||||
headers: { "Content-Type": "text/plain" },
|
||||
uploadProgress: "uploadprogress",
|
||||
noAllowPreflight: 1,
|
||||
},
|
||||
{ pass: 0,
|
||||
method: "POST",
|
||||
body: "hi there",
|
||||
|
@ -27,12 +27,12 @@ function uploadprogress()
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.upload.onprogress = uploadprogress;
|
||||
xhr.onuploadprogress = uploadprogress;
|
||||
var event = document.createEvent("ProgressEvent");
|
||||
event.initProgressEvent("progress", false, false, false, false, 0);
|
||||
xhr.upload.dispatchEvent(event);
|
||||
event.initProgressEvent("uploadprogress", false, false, false, false, 0);
|
||||
xhr.dispatchEvent(event);
|
||||
ok(called,
|
||||
"XMLHttpRequest.upload.onprogress sets upload progress event listener");
|
||||
"XMLHttpRequest.onuploadprogress sets uploadprogress event listener");
|
||||
|
||||
|
||||
</script>
|
||||
|
@ -105,7 +105,7 @@ function test(trusted, type, removeAddedListener, removeSetListener, allowUntrus
|
||||
}
|
||||
|
||||
var events =
|
||||
["load", "error", "progress", "readystatechange", "foo"];
|
||||
["load", "error", "progress", "uploadprogress", "readystatechange", "foo"];
|
||||
|
||||
do {
|
||||
var e = events.shift();
|
||||
|
@ -104,6 +104,10 @@ function start(obj) {
|
||||
function (evt) {
|
||||
logEvent(evt);
|
||||
}
|
||||
xhr.onuploadprogress =
|
||||
function (evt) {
|
||||
logEvent(evt);
|
||||
}
|
||||
|
||||
if ("upload" in xhr) {
|
||||
xhr.upload.onloadstart =
|
||||
@ -273,6 +277,7 @@ var tests =
|
||||
{ method: "POST", withUpload: small, testAbort: false, testRedirectError: false, testNetworkError: false,
|
||||
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
|
||||
{target: UPLOAD, type: "loadstart", optional: false},
|
||||
{target: XHR, type: "uploadprogress", optional: true},
|
||||
{target: UPLOAD, type: "progress", optional: true},
|
||||
{target: UPLOAD, type: "load", optional: false},
|
||||
{target: UPLOAD, type: "loadend", optional: false},
|
||||
@ -289,6 +294,7 @@ var tests =
|
||||
{ method: "POST", withUpload: small, testAbort: false, testRedirectError: true, testNetworkError: false,
|
||||
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
|
||||
{target: UPLOAD, type: "loadstart", optional: false},
|
||||
{target: XHR, type: "uploadprogress", optional: true},
|
||||
{target: UPLOAD, type: "progress", optional: true},
|
||||
{target: XHR, type: "error", optional: false},
|
||||
{target: XHR, type: "loadend", optional: false},
|
||||
@ -297,6 +303,7 @@ var tests =
|
||||
{ method: "POST", withUpload: small, testAbort: false, testRedirectError: false, testNetworkError: true,
|
||||
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
|
||||
{target: UPLOAD, type: "loadstart", optional: false},
|
||||
{target: XHR, type: "uploadprogress", optional: true},
|
||||
{target: UPLOAD, type: "progress", optional: true},
|
||||
{target: XHR, type: "error", optional: false},
|
||||
{target: XHR, type: "loadend", optional: false},
|
||||
@ -306,6 +313,7 @@ var tests =
|
||||
{ method: "POST", withUpload: mid, testAbort: false, testRedirectError: false, testNetworkError: false,
|
||||
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
|
||||
{target: UPLOAD, type: "loadstart", optional: false},
|
||||
{target: XHR, type: "uploadprogress", optional: true},
|
||||
{target: UPLOAD, type: "progress", optional: true},
|
||||
{target: UPLOAD, type: "load", optional: false},
|
||||
{target: UPLOAD, type: "loadend", optional: false},
|
||||
@ -322,6 +330,7 @@ var tests =
|
||||
{ method: "POST", withUpload: mid, testAbort: false, testRedirectError: true, testNetworkError: false,
|
||||
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
|
||||
{target: UPLOAD, type: "loadstart", optional: false},
|
||||
{target: XHR, type: "uploadprogress", optional: true},
|
||||
{target: UPLOAD, type: "progress", optional: true},
|
||||
{target: XHR, type: "error", optional: false},
|
||||
{target: XHR, type: "loadend", optional: false},
|
||||
@ -330,6 +339,7 @@ var tests =
|
||||
{ method: "POST", withUpload: mid, testAbort: false, testRedirectError: false, testNetworkError: true,
|
||||
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
|
||||
{target: UPLOAD, type: "loadstart", optional: false},
|
||||
{target: XHR, type: "uploadprogress", optional: true},
|
||||
{target: UPLOAD, type: "progress", optional: true},
|
||||
{target: XHR, type: "error", optional: false},
|
||||
{target: XHR, type: "loadend", optional: false},
|
||||
@ -339,6 +349,7 @@ var tests =
|
||||
{ method: "POST", withUpload: large, testAbort: false, testRedirectError: false, testNetworkError: false,
|
||||
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
|
||||
{target: UPLOAD, type: "loadstart", optional: false},
|
||||
{target: XHR, type: "uploadprogress", optional: true},
|
||||
{target: UPLOAD, type: "progress", optional: true},
|
||||
{target: UPLOAD, type: "load", optional: false},
|
||||
{target: UPLOAD, type: "loadend", optional: false},
|
||||
@ -355,6 +366,7 @@ var tests =
|
||||
{ method: "POST", withUpload: large, testAbort: false, testRedirectError: true, testNetworkError: false,
|
||||
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
|
||||
{target: UPLOAD, type: "loadstart", optional: false},
|
||||
{target: XHR, type: "uploadprogress", optional: true},
|
||||
{target: UPLOAD, type: "progress", optional: true},
|
||||
{target: XHR, type: "error", optional: false},
|
||||
{target: XHR, type: "loadend", optional: false},
|
||||
@ -363,6 +375,7 @@ var tests =
|
||||
{ method: "POST", withUpload: large, testAbort: false, testRedirectError: false, testNetworkError: true,
|
||||
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
|
||||
{target: UPLOAD, type: "loadstart", optional: false},
|
||||
{target: XHR, type: "uploadprogress", optional: true},
|
||||
{target: UPLOAD, type: "progress", optional: true},
|
||||
{target: XHR, type: "error", optional: false},
|
||||
{target: XHR, type: "loadend", optional: false},
|
||||
|
@ -133,3 +133,4 @@ NoExposedPropsWarning=Exposing chrome JS objects to content without __exposedPro
|
||||
MutationEventWarning=Use of Mutation Events is deprecated. Use MutationObserver instead.
|
||||
# LOCALIZATION NOTE: Do not translate "Blob", "mozSlice", or "slice"
|
||||
MozSliceWarning=Use of mozSlice on the Blob object is deprecated. Use slice instead.
|
||||
OnuploadprogressWarning=Use of XMLHttpRequest's onuploadprogress attribute is deprecated.
|
||||
|
@ -127,6 +127,9 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
||||
void sendAsBinary(DOMString body);
|
||||
any getInterface(IID iid);
|
||||
|
||||
[TreatNonCallableAsNull, GetterInfallible=MainThread]
|
||||
attribute Function? onuploadprogress;
|
||||
|
||||
[Infallible]
|
||||
readonly attribute boolean mozAnon;
|
||||
|
||||
|
@ -97,6 +97,18 @@ public:
|
||||
|
||||
#undef IMPL_GETTER_AND_SETTER
|
||||
|
||||
JSObject*
|
||||
GetOnuploadprogress(JSContext* /* unused */, ErrorResult& aRv)
|
||||
{
|
||||
aRv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NULL;
|
||||
}
|
||||
void
|
||||
SetOnuploadprogress(JSContext* /* unused */, JSObject* aListener, ErrorResult& aRv)
|
||||
{
|
||||
aRv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
GetReadyState() const
|
||||
{
|
||||
|
@ -64,7 +64,6 @@ CPPSRCS = \
|
||||
testVersion.cpp \
|
||||
testXDR.cpp \
|
||||
testProfileStrings.cpp \
|
||||
testJSEvaluateScript.cpp \
|
||||
$(NULL)
|
||||
|
||||
CSRCS = \
|
||||
|
@ -1,50 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sw=4 et tw=99:
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
BEGIN_TEST(testJSEvaluateScript)
|
||||
{
|
||||
jsvalRoot proto(cx);
|
||||
JSObject *obj = JS_NewObject(cx, NULL, NULL, global);
|
||||
CHECK(obj);
|
||||
|
||||
uint32_t options = JS_GetOptions(cx);
|
||||
CHECK(options & JSOPTION_VAROBJFIX);
|
||||
|
||||
static const char src[] = "var x = 5;";
|
||||
|
||||
JS::Value retval;
|
||||
CHECK(JS_EvaluateScript(cx, obj, src, sizeof(src) - 1, __FILE__, __LINE__,
|
||||
&retval));
|
||||
|
||||
JSBool hasProp = JS_TRUE;
|
||||
CHECK(JS_AlreadyHasOwnProperty(cx, obj, "x", &hasProp));
|
||||
CHECK(!hasProp);
|
||||
|
||||
hasProp = JS_FALSE;
|
||||
CHECK(JS_HasProperty(cx, global, "x", &hasProp));
|
||||
CHECK(hasProp);
|
||||
|
||||
// Now do the same thing, but without JSOPTION_VAROBJFIX
|
||||
JS_SetOptions(cx, options & ~JSOPTION_VAROBJFIX);
|
||||
|
||||
static const char src2[] = "var y = 5;";
|
||||
|
||||
CHECK(JS_EvaluateScript(cx, obj, src2, sizeof(src2) - 1, __FILE__, __LINE__,
|
||||
&retval));
|
||||
|
||||
hasProp = JS_FALSE;
|
||||
CHECK(JS_AlreadyHasOwnProperty(cx, obj, "y", &hasProp));
|
||||
CHECK(hasProp);
|
||||
|
||||
hasProp = JS_TRUE;
|
||||
CHECK(JS_AlreadyHasOwnProperty(cx, global, "y", &hasProp));
|
||||
CHECK(!hasProp);
|
||||
|
||||
return true;
|
||||
}
|
||||
END_TEST(testJSEvaluateScript)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user