From 380d2ba82cce4113d84e190a8d49e56da5dd4347 Mon Sep 17 00:00:00 2001 From: Jason Duell Date: Sat, 21 Jul 2012 20:05:37 -0700 Subject: [PATCH] Backout f142f32a98a3 (Bug 775317) and ef14686c31d0 (Bug 761278). r=bustage --- .../base/public/nsDeprecatedOperationList.h | 1 + content/base/public/nsIXMLHttpRequest.idl | 16 +++++- content/base/src/nsXMLHttpRequest.cpp | 35 ++++++++++++- content/base/src/nsXMLHttpRequest.h | 23 +++++++++ .../base/test/file_CrossSiteXHR_inner.html | 13 +++-- .../test/file_CrossSiteXHR_inner_data.sjs | 13 +++-- content/base/test/test_CrossSiteXHR.html | 13 +++++ .../base/test/test_XHR_onuploadprogress.html | 8 +-- content/base/test/test_bug372964.html | 2 +- content/base/test/test_bug435425.html | 13 +++++ dom/locales/en-US/chrome/dom/dom.properties | 1 + dom/webidl/XMLHttpRequest.webidl | 3 ++ dom/workers/XMLHttpRequest.h | 12 +++++ js/src/jsapi-tests/Makefile.in | 1 - js/src/jsapi-tests/testJSEvaluateScript.cpp | 50 ------------------- 15 files changed, 139 insertions(+), 65 deletions(-) delete mode 100644 js/src/jsapi-tests/testJSEvaluateScript.cpp diff --git a/content/base/public/nsDeprecatedOperationList.h b/content/base/public/nsDeprecatedOperationList.h index e75b70c4e117..46d4f6b53bc4 100644 --- a/content/base/public/nsDeprecatedOperationList.h +++ b/content/base/public/nsDeprecatedOperationList.h @@ -48,3 +48,4 @@ DEPRECATED_OPERATION(DOMExceptionCode) DEPRECATED_OPERATION(NoExposedProps) DEPRECATED_OPERATION(MutationEvent) DEPRECATED_OPERATION(MozSlice) +DEPRECATED_OPERATION(Onuploadprogress) diff --git a/content/base/public/nsIXMLHttpRequest.idl b/content/base/public/nsIXMLHttpRequest.idl index c931180b9d8a..399cdaf359f4 100644 --- a/content/base/public/nsIXMLHttpRequest.idl +++ b/content/base/public/nsIXMLHttpRequest.idl @@ -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++ diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index bb02286e64a1..c5031037eb8d 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -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& 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& 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, diff --git a/content/base/src/nsXMLHttpRequest.h b/content/base/src/nsXMLHttpRequest.h index c2031ea0a39f..b16a4b68abe0 100644 --- a/content/base/src/nsXMLHttpRequest.h +++ b/content/base/src/nsXMLHttpRequest.h @@ -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 mCORSPreflightChannel; nsTArray mCORSUnsafeHeaders; + nsRefPtr mOnUploadProgressListener; nsRefPtr mOnReadystatechangeListener; nsCOMPtr mXMLParserStreamListener; diff --git a/content/base/test/file_CrossSiteXHR_inner.html b/content/base/test/file_CrossSiteXHR_inner.html index eea1a727df04..6a9284381a9d 100644 --- a/content/base/test/file_CrossSiteXHR_inner.html +++ b/content/base/test/file_CrossSiteXHR_inner.html @@ -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; diff --git a/content/base/test/file_CrossSiteXHR_inner_data.sjs b/content/base/test/file_CrossSiteXHR_inner_data.sjs index c59ceb5f822b..080827c5784d 100644 --- a/content/base/test/file_CrossSiteXHR_inner_data.sjs +++ b/content/base/test/file_CrossSiteXHR_inner_data.sjs @@ -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\ diff --git a/content/base/test/test_CrossSiteXHR.html b/content/base/test/test_CrossSiteXHR.html index 3735846ee2ed..1a08cae192ca 100644 --- a/content/base/test/test_CrossSiteXHR.html +++ b/content/base/test/test_CrossSiteXHR.html @@ -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", diff --git a/content/base/test/test_XHR_onuploadprogress.html b/content/base/test/test_XHR_onuploadprogress.html index 1018682d31cf..5c52727f1c8c 100644 --- a/content/base/test/test_XHR_onuploadprogress.html +++ b/content/base/test/test_XHR_onuploadprogress.html @@ -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"); diff --git a/content/base/test/test_bug372964.html b/content/base/test/test_bug372964.html index db83fd6d79a4..86330df0a111 100644 --- a/content/base/test/test_bug372964.html +++ b/content/base/test/test_bug372964.html @@ -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(); diff --git a/content/base/test/test_bug435425.html b/content/base/test/test_bug435425.html index 33d4c3577d53..b26e231eeda0 100644 --- a/content/base/test/test_bug435425.html +++ b/content/base/test/test_bug435425.html @@ -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}, diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties index 1cb9963c6204..7619e2250c35 100644 --- a/dom/locales/en-US/chrome/dom/dom.properties +++ b/dom/locales/en-US/chrome/dom/dom.properties @@ -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. diff --git a/dom/webidl/XMLHttpRequest.webidl b/dom/webidl/XMLHttpRequest.webidl index acbfa7352ff1..5c435fc988d8 100644 --- a/dom/webidl/XMLHttpRequest.webidl +++ b/dom/webidl/XMLHttpRequest.webidl @@ -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; diff --git a/dom/workers/XMLHttpRequest.h b/dom/workers/XMLHttpRequest.h index a7415d920d26..2de709e9c5ca 100644 --- a/dom/workers/XMLHttpRequest.h +++ b/dom/workers/XMLHttpRequest.h @@ -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 { diff --git a/js/src/jsapi-tests/Makefile.in b/js/src/jsapi-tests/Makefile.in index 20b689b69012..c7db41909c43 100644 --- a/js/src/jsapi-tests/Makefile.in +++ b/js/src/jsapi-tests/Makefile.in @@ -64,7 +64,6 @@ CPPSRCS = \ testVersion.cpp \ testXDR.cpp \ testProfileStrings.cpp \ - testJSEvaluateScript.cpp \ $(NULL) CSRCS = \ diff --git a/js/src/jsapi-tests/testJSEvaluateScript.cpp b/js/src/jsapi-tests/testJSEvaluateScript.cpp deleted file mode 100644 index 413d72806cba..000000000000 --- a/js/src/jsapi-tests/testJSEvaluateScript.cpp +++ /dev/null @@ -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) - -