2001-09-25 22:43:09 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
2011-09-18 09:22:17 +00:00
|
|
|
#ifndef nsJSEnvironment_h
|
|
|
|
#define nsJSEnvironment_h
|
1998-07-16 01:16:47 +00:00
|
|
|
|
|
|
|
#include "nsIScriptContext.h"
|
2012-03-24 08:18:21 +00:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2000-06-20 03:45:21 +00:00
|
|
|
#include "nsIObserver.h"
|
2004-02-11 22:22:05 +00:00
|
|
|
#include "prtime.h"
|
2007-03-08 11:17:16 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2012-01-25 18:59:55 +00:00
|
|
|
#include "nsIXPConnect.h"
|
2012-03-11 08:53:05 +00:00
|
|
|
#include "nsIArray.h"
|
2012-06-15 02:31:55 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-08-29 04:30:06 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2007-01-11 00:02:58 +00:00
|
|
|
|
2013-04-30 17:41:22 +00:00
|
|
|
class nsICycleCollectorListener;
|
2005-07-29 15:11:08 +00:00
|
|
|
class nsIXPConnectJSObjectHolder;
|
2011-09-22 22:13:36 +00:00
|
|
|
class nsRootedJSValueArray;
|
2011-10-03 19:11:31 +00:00
|
|
|
class nsScriptNameSpaceManager;
|
2013-09-04 21:06:54 +00:00
|
|
|
class nsCycleCollectionNoteRootCallback;
|
2013-04-30 17:41:22 +00:00
|
|
|
|
2011-04-28 22:48:52 +00:00
|
|
|
namespace mozilla {
|
2011-04-28 22:48:51 +00:00
|
|
|
template <class> class Maybe;
|
2013-11-20 22:35:16 +00:00
|
|
|
struct CycleCollectorResults;
|
2010-03-30 05:51:52 +00:00
|
|
|
}
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2012-03-12 23:25:03 +00:00
|
|
|
// The amount of time we wait between a request to GC (due to leaving
|
|
|
|
// a page) and doing the actual GC.
|
|
|
|
#define NS_GC_DELAY 4000 // ms
|
|
|
|
|
2013-08-14 21:00:03 +00:00
|
|
|
class nsJSContext : public nsIScriptContext
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
1998-07-16 01:16:47 +00:00
|
|
|
public:
|
2013-08-19 23:24:29 +00:00
|
|
|
nsJSContext(bool aGCOnDestruction, nsIScriptGlobalObject* aGlobalObject);
|
1999-03-20 01:54:12 +00:00
|
|
|
virtual ~nsJSContext();
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2007-03-08 11:17:16 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2009-05-07 18:19:36 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsJSContext,
|
|
|
|
nsIScriptContext)
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2013-01-17 02:50:26 +00:00
|
|
|
virtual nsresult EvaluateString(const nsAString& aScript,
|
2013-05-10 18:22:21 +00:00
|
|
|
JS::Handle<JSObject*> aScopeObject,
|
2013-01-17 02:50:26 +00:00
|
|
|
JS::CompileOptions &aOptions,
|
|
|
|
bool aCoerceToString,
|
2013-09-11 23:42:09 +00:00
|
|
|
JS::Value* aRetValue,
|
|
|
|
void **aOffThreadToken = nullptr) MOZ_OVERRIDE;
|
2000-03-29 01:18:21 +00:00
|
|
|
|
2006-06-13 03:07:47 +00:00
|
|
|
virtual nsresult BindCompiledEventHandler(nsISupports *aTarget,
|
2013-05-12 05:17:42 +00:00
|
|
|
JS::Handle<JSObject*> aScope,
|
|
|
|
JS::Handle<JSObject*> aHandler,
|
2013-06-05 16:15:48 +00:00
|
|
|
JS::MutableHandle<JSObject*> aBoundHandler) MOZ_OVERRIDE;
|
1999-12-07 22:14:17 +00:00
|
|
|
|
2013-06-05 16:15:48 +00:00
|
|
|
virtual nsIScriptGlobalObject *GetGlobalObject() MOZ_OVERRIDE;
|
2012-12-09 17:23:19 +00:00
|
|
|
inline nsIScriptGlobalObject *GetGlobalObjectRef() { return mGlobalObjectRef; }
|
2012-04-12 18:21:12 +00:00
|
|
|
|
2013-06-05 16:15:48 +00:00
|
|
|
virtual JSContext* GetNativeContext() MOZ_OVERRIDE;
|
|
|
|
virtual nsresult InitContext() MOZ_OVERRIDE;
|
|
|
|
virtual bool IsContextInitialized() MOZ_OVERRIDE;
|
2006-06-13 03:07:47 +00:00
|
|
|
|
2013-06-05 16:15:48 +00:00
|
|
|
virtual nsresult SetProperty(JS::Handle<JSObject*> aTarget, const char* aPropName, nsISupports* aVal) MOZ_OVERRIDE;
|
2006-06-13 03:07:47 +00:00
|
|
|
|
2013-06-05 16:15:48 +00:00
|
|
|
virtual bool GetProcessingScriptTag() MOZ_OVERRIDE;
|
|
|
|
virtual void SetProcessingScriptTag(bool aResult) MOZ_OVERRIDE;
|
2013-01-15 11:46:35 +00:00
|
|
|
|
2013-06-05 16:15:48 +00:00
|
|
|
virtual nsresult InitClasses(JS::Handle<JSObject*> aGlobalObj) MOZ_OVERRIDE;
|
2005-07-30 20:57:07 +00:00
|
|
|
|
2013-06-05 16:15:48 +00:00
|
|
|
virtual void WillInitializeContext() MOZ_OVERRIDE;
|
|
|
|
virtual void DidInitializeContext() MOZ_OVERRIDE;
|
2006-06-13 03:07:47 +00:00
|
|
|
|
2013-09-04 21:06:55 +00:00
|
|
|
virtual void SetWindowProxy(JS::Handle<JSObject*> aWindowProxy) MOZ_OVERRIDE;
|
|
|
|
virtual JSObject* GetWindowProxy() MOZ_OVERRIDE;
|
|
|
|
virtual JSObject* GetWindowProxyPreserveColor() MOZ_OVERRIDE;
|
|
|
|
|
2007-01-11 00:02:58 +00:00
|
|
|
static void LoadStart();
|
2007-10-21 16:46:54 +00:00
|
|
|
static void LoadEnd();
|
2007-01-11 00:02:58 +00:00
|
|
|
|
2012-06-30 21:16:32 +00:00
|
|
|
enum IsCompartment {
|
|
|
|
CompartmentGC,
|
|
|
|
NonCompartmentGC
|
|
|
|
};
|
|
|
|
|
|
|
|
enum IsShrinking {
|
|
|
|
ShrinkingGC,
|
|
|
|
NonShrinkingGC
|
|
|
|
};
|
|
|
|
|
|
|
|
enum IsIncremental {
|
|
|
|
IncrementalGC,
|
|
|
|
NonIncrementalGC
|
|
|
|
};
|
|
|
|
|
2013-08-19 23:24:29 +00:00
|
|
|
// Setup all the statics etc - safe to call multiple times after Startup().
|
|
|
|
void EnsureStatics();
|
|
|
|
|
2013-01-27 20:35:12 +00:00
|
|
|
static void GarbageCollectNow(JS::gcreason::Reason reason,
|
2012-06-30 21:16:32 +00:00
|
|
|
IsIncremental aIncremental = NonIncrementalGC,
|
|
|
|
IsCompartment aCompartment = NonCompartmentGC,
|
2012-08-01 01:39:39 +00:00
|
|
|
IsShrinking aShrinking = NonShrinkingGC,
|
|
|
|
int64_t aSliceMillis = 0);
|
2011-12-27 11:59:29 +00:00
|
|
|
static void ShrinkGCBuffersNow();
|
2013-12-22 14:58:19 +00:00
|
|
|
|
2012-01-30 20:06:18 +00:00
|
|
|
// If aExtraForgetSkippableCalls is -1, forgetSkippable won't be
|
|
|
|
// called even if the previous collection was GC.
|
2012-07-30 14:20:58 +00:00
|
|
|
static void CycleCollectNow(nsICycleCollectorListener *aListener = nullptr,
|
2013-11-20 22:35:17 +00:00
|
|
|
int32_t aExtraForgetSkippableCalls = 0);
|
2013-12-22 14:58:19 +00:00
|
|
|
|
|
|
|
// If aSliceTime is negative, the CC will run to completion. If aSliceTime
|
|
|
|
// is 0, only a minimum quantum of work will be done. Otherwise, aSliceTime
|
|
|
|
// will be used as the time budget for the slice, in ms.
|
2014-01-01 19:00:35 +00:00
|
|
|
static void RunCycleCollectorSlice(int64_t aSliceTime);
|
2013-12-22 14:58:19 +00:00
|
|
|
|
2013-11-20 22:35:16 +00:00
|
|
|
static void BeginCycleCollectionCallback();
|
|
|
|
static void EndCycleCollectionCallback(mozilla::CycleCollectorResults &aResults);
|
2011-02-16 23:47:12 +00:00
|
|
|
|
2013-01-27 20:35:12 +00:00
|
|
|
static void PokeGC(JS::gcreason::Reason aReason, int aDelay = 0);
|
2011-02-16 23:47:12 +00:00
|
|
|
static void KillGCTimer();
|
|
|
|
|
2011-12-27 11:59:29 +00:00
|
|
|
static void PokeShrinkGCBuffers();
|
|
|
|
static void KillShrinkGCBuffersTimer();
|
|
|
|
|
2011-02-16 23:47:12 +00:00
|
|
|
static void MaybePokeCC();
|
|
|
|
static void KillCCTimer();
|
2013-12-21 14:35:08 +00:00
|
|
|
static void KillICCTimer();
|
2012-05-09 18:53:23 +00:00
|
|
|
static void KillFullGCTimer();
|
2012-06-11 04:27:59 +00:00
|
|
|
static void KillInterSliceGCTimer();
|
2011-02-16 23:47:12 +00:00
|
|
|
|
2013-03-07 18:53:19 +00:00
|
|
|
// Calling LikelyShortLivingObjectCreated() makes a GC more likely.
|
|
|
|
static void LikelyShortLivingObjectCreated();
|
|
|
|
|
2013-06-05 16:15:48 +00:00
|
|
|
virtual void GC(JS::gcreason::Reason aReason) MOZ_OVERRIDE;
|
2009-02-12 12:06:59 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint32_t CleanupsSinceLastGC();
|
2012-01-30 20:06:18 +00:00
|
|
|
|
2012-01-26 15:03:21 +00:00
|
|
|
nsIScriptGlobalObject* GetCachedGlobalObject()
|
|
|
|
{
|
|
|
|
// Verify that we have a global so that this
|
|
|
|
// does always return a null when GetGlobalObject() is null.
|
2013-09-04 21:06:57 +00:00
|
|
|
JSObject* global = GetWindowProxy();
|
2012-07-30 14:20:58 +00:00
|
|
|
return global ? mGlobalObjectRef.get() : nullptr;
|
2012-01-26 15:03:21 +00:00
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
protected:
|
1998-12-30 21:35:35 +00:00
|
|
|
nsresult InitializeExternalClasses();
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2006-06-13 03:07:47 +00:00
|
|
|
// Helper to convert xpcom datatypes to jsvals.
|
2010-01-25 16:48:07 +00:00
|
|
|
nsresult ConvertSupportsTojsvals(nsISupports *aArgs,
|
2013-05-02 09:12:46 +00:00
|
|
|
JS::Handle<JSObject*> aScope,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t *aArgc,
|
2013-04-11 22:52:10 +00:00
|
|
|
JS::Value **aArgv,
|
2011-09-22 22:13:36 +00:00
|
|
|
mozilla::Maybe<nsRootedJSValueArray> &aPoolRelease);
|
2006-06-13 03:07:47 +00:00
|
|
|
|
2013-04-11 22:52:10 +00:00
|
|
|
nsresult AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv);
|
2006-06-13 03:07:47 +00:00
|
|
|
|
|
|
|
// given an nsISupports object (presumably an event target or some other
|
|
|
|
// DOM object), get (or create) the JSObject wrapping it.
|
2013-05-02 09:12:46 +00:00
|
|
|
nsresult JSObjectFromInterface(nsISupports *aSup,
|
|
|
|
JS::Handle<JSObject*> aScript,
|
2006-06-13 03:07:47 +00:00
|
|
|
JSObject **aRet);
|
|
|
|
|
2009-05-20 02:11:01 +00:00
|
|
|
// Report the pending exception on our mContext, if any. This
|
|
|
|
// function will set aside the frame chain on mContext before
|
|
|
|
// reporting.
|
|
|
|
void ReportPendingException();
|
2013-09-04 21:06:56 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
private:
|
2009-05-07 18:19:36 +00:00
|
|
|
void DestroyJSContext();
|
|
|
|
|
|
|
|
nsrefcnt GetCCRefcnt();
|
2007-11-01 22:51:57 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
JSContext *mContext;
|
2013-09-04 21:06:56 +00:00
|
|
|
JS::Heap<JSObject*> mWindowProxy;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsInitialized;
|
|
|
|
bool mGCOnDestruction;
|
2013-01-15 11:46:35 +00:00
|
|
|
bool mProcessingScriptTag;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2008-01-18 21:28:42 +00:00
|
|
|
PRTime mOperationCallbackTime;
|
2001-10-31 08:39:09 +00:00
|
|
|
|
2009-06-12 00:52:47 +00:00
|
|
|
PRTime mModalStateTime;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mModalStateDepth;
|
2009-06-12 00:52:47 +00:00
|
|
|
|
2012-05-09 18:53:23 +00:00
|
|
|
nsJSContext *mNext;
|
|
|
|
nsJSContext **mPrev;
|
|
|
|
|
2010-09-03 21:15:50 +00:00
|
|
|
// mGlobalObjectRef ensures that the outer window stays alive as long as the
|
|
|
|
// context does. It is eventually collected by the cycle collector.
|
2011-04-28 20:28:54 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> mGlobalObjectRef;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2013-12-10 23:10:01 +00:00
|
|
|
static void JSOptionChangedCallback(const char *pref, void *data);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2013-08-08 22:53:04 +00:00
|
|
|
static bool DOMOperationCallback(JSContext *cx);
|
1998-07-16 01:16:47 +00:00
|
|
|
};
|
|
|
|
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
class nsIJSRuntimeService;
|
2013-08-29 04:30:06 +00:00
|
|
|
class nsIPrincipal;
|
|
|
|
class nsPIDOMWindow;
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
2013-08-19 23:24:29 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-08-19 23:24:29 +00:00
|
|
|
|
2013-08-19 23:24:29 +00:00
|
|
|
void StartupJSEnvironment();
|
|
|
|
void ShutdownJSEnvironment();
|
|
|
|
|
|
|
|
// Get the NameSpaceManager, creating if necessary
|
|
|
|
nsScriptNameSpaceManager* GetNameSpaceManager();
|
|
|
|
|
2013-08-29 04:30:06 +00:00
|
|
|
// Runnable that's used to do async error reporting
|
|
|
|
class AsyncErrorReporter : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// aWindow may be null if this error report is not associated with a window
|
|
|
|
AsyncErrorReporter(JSRuntime* aRuntime,
|
|
|
|
JSErrorReport* aErrorReport,
|
|
|
|
const char* aFallbackMessage,
|
2013-10-30 23:17:36 +00:00
|
|
|
bool aIsChromeError, // To determine category
|
2013-08-29 04:30:06 +00:00
|
|
|
nsPIDOMWindow* aWindow);
|
|
|
|
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
ReportError();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Do the actual error reporting
|
|
|
|
void ReportError();
|
|
|
|
|
|
|
|
nsString mErrorMsg;
|
|
|
|
nsString mFileName;
|
|
|
|
nsString mSourceLine;
|
|
|
|
nsCString mCategory;
|
|
|
|
uint32_t mLineNumber;
|
|
|
|
uint32_t mColumn;
|
|
|
|
uint32_t mFlags;
|
|
|
|
uint64_t mInnerWindowID;
|
|
|
|
};
|
|
|
|
|
2013-08-19 23:24:29 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2006-06-13 03:07:47 +00:00
|
|
|
// An interface for fast and native conversion to/from nsIArray. If an object
|
|
|
|
// supports this interface, JS can reach directly in for the argv, and avoid
|
|
|
|
// nsISupports conversion. If this interface is not supported, the object will
|
|
|
|
// be queried for nsIArray, and everything converted via xpcom objects.
|
|
|
|
#define NS_IJSARGARRAY_IID \
|
2012-03-11 08:53:05 +00:00
|
|
|
{ 0xb6acdac8, 0xf5c6, 0x432c, \
|
|
|
|
{ 0xa8, 0x6e, 0x33, 0xee, 0xb1, 0xb0, 0xcd, 0xdc } }
|
2001-11-27 09:46:38 +00:00
|
|
|
|
2012-03-11 08:53:05 +00:00
|
|
|
class nsIJSArgArray : public nsIArray
|
2006-06-13 03:07:47 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IJSARGARRAY_IID)
|
|
|
|
// Bug 312003 describes why this must be "void **", but after calling argv
|
2013-04-11 22:52:10 +00:00
|
|
|
// may be cast to JS::Value* and the args found at:
|
|
|
|
// ((JS::Value*)argv)[0], ..., ((JS::Value*)argv)[argc - 1]
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual nsresult GetArgs(uint32_t *argc, void **argv) = 0;
|
1998-07-16 01:16:47 +00:00
|
|
|
};
|
|
|
|
|
2006-06-13 03:07:47 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIJSArgArray, NS_IJSARGARRAY_IID)
|
|
|
|
|
1999-01-06 18:53:59 +00:00
|
|
|
/* prototypes */
|
2008-09-06 22:21:43 +00:00
|
|
|
void NS_ScriptErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);
|
1999-01-06 18:53:59 +00:00
|
|
|
|
2011-07-17 19:09:13 +00:00
|
|
|
JSObject* NS_DOMReadStructuredClone(JSContext* cx,
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-09 03:54:10 +00:00
|
|
|
JSStructuredCloneReader* reader, uint32_t tag,
|
|
|
|
uint32_t data, void* closure);
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2013-08-08 22:53:04 +00:00
|
|
|
bool NS_DOMWriteStructuredClone(JSContext* cx,
|
|
|
|
JSStructuredCloneWriter* writer,
|
|
|
|
JS::Handle<JSObject*> obj, void *closure);
|
2011-07-17 19:09:13 +00:00
|
|
|
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-09 03:54:10 +00:00
|
|
|
void NS_DOMStructuredCloneError(JSContext* cx, uint32_t errorid);
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2011-09-18 09:22:17 +00:00
|
|
|
#endif /* nsJSEnvironment_h */
|