Bug 587931: Implement document.currentScript and beforescriptexecute/afterscriptexecute events. r=mrbkap a=sicking
authorJonas Sicking <jonas@sicking.cc>
Thu, 16 Sep 2010 01:48:47 -0700
changeset 54146 406cba7534451f3a3fe1aef464acfdf749a4ccc2
parent 54145 de02d0483a7fb6d053d12c35f6f3b151b7e4518d
child 54147 f38ef1080bfe788c6ee78c167a4e03087e5f79af
push id15783
push usersicking@mozilla.com
push dateThu, 16 Sep 2010 08:50:07 +0000
treeherdermozilla-central@406cba753445 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, sicking
bugs587931
milestone2.0b7pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 587931: Implement document.currentScript and beforescriptexecute/afterscriptexecute events. r=mrbkap a=sicking
content/base/src/nsContentUtils.cpp
content/base/src/nsDocument.cpp
content/base/src/nsGkAtomList.h
content/base/src/nsScriptLoader.cpp
content/base/test/Makefile.in
content/base/test/test_bug587931.html
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMEvent.h
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfo.h
dom/interfaces/core/nsIDOMNSDocument.idl
widget/public/nsGUIEvent.h
widget/src/xpwidgets/nsBaseWidget.cpp
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -571,16 +571,18 @@ nsContentUtils::InitializeEventTable() {
                                                 (EventNameType_HTMLXUL | EventNameType_SVGSVG), NS_EVENT },
     { nsGkAtoms::onhashchange,                  NS_HASHCHANGE, EventNameType_HTMLXUL, NS_EVENT },
     { nsGkAtoms::onreadystatechange,            NS_READYSTATECHANGE, EventNameType_HTMLXUL },
     { nsGkAtoms::onbeforeunload,                NS_BEFORE_PAGE_UNLOAD, EventNameType_HTMLXUL, NS_EVENT },
     { nsGkAtoms::onabort,                       NS_IMAGE_ABORT,
                                                 (EventNameType_HTMLXUL | EventNameType_SVGSVG), NS_EVENT },
     { nsGkAtoms::onerror,                       NS_LOAD_ERROR,
                                                 (EventNameType_HTMLXUL | EventNameType_SVGSVG), NS_EVENT },
+    { nsGkAtoms::onbeforescriptexecute,         NS_BEFORE_SCRIPT_EXECUTE, EventNameType_HTMLXUL, NS_EVENT },
+    { nsGkAtoms::onafterscriptexecute,          NS_AFTER_SCRIPT_EXECUTE, EventNameType_HTMLXUL, NS_EVENT },
 
     { nsGkAtoms::onDOMAttrModified,             NS_MUTATION_ATTRMODIFIED, EventNameType_HTMLXUL, NS_MUTATION_EVENT },
     { nsGkAtoms::onDOMCharacterDataModified,    NS_MUTATION_CHARACTERDATAMODIFIED, EventNameType_HTMLXUL, NS_MUTATION_EVENT },
     { nsGkAtoms::onDOMNodeInserted,             NS_MUTATION_NODEINSERTED, EventNameType_HTMLXUL, NS_MUTATION_EVENT },
     { nsGkAtoms::onDOMNodeRemoved,              NS_MUTATION_NODEREMOVED, EventNameType_HTMLXUL, NS_MUTATION_EVENT },
     { nsGkAtoms::onDOMNodeInsertedIntoDocument, NS_MUTATION_NODEINSERTEDINTODOCUMENT, EventNameType_HTMLXUL, NS_MUTATION_EVENT },
     { nsGkAtoms::onDOMNodeRemovedFromDocument,  NS_MUTATION_NODEREMOVEDFROMDOCUMENT, EventNameType_HTMLXUL, NS_MUTATION_EVENT },
     { nsGkAtoms::onDOMSubtreeModified,          NS_MUTATION_SUBTREEMODIFIED, EventNameType_HTMLXUL, NS_MUTATION_EVENT },
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -2809,16 +2809,29 @@ nsDocument::GetActiveElement(nsIDOMEleme
     return NS_OK;
   }
 
   // If we couldn't get a BODY, return the root element.
   return GetDocumentElement(aElement);
 }
 
 NS_IMETHODIMP
+nsDocument::GetCurrentScript(nsIDOMElement **aElement)
+{
+  nsIScriptElement* script = mScriptLoader->GetCurrentScript();
+  if (script) {
+    return CallQueryInterface(script, aElement);
+  }
+  
+  *aElement = nsnull;
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsDocument::ElementFromPoint(float aX, float aY, nsIDOMElement** aReturn)
 {
   return ElementFromPointHelper(aX, aY, PR_FALSE, PR_TRUE, aReturn);
 }
 
 nsresult
 nsDocument::ElementFromPointHelper(float aX, float aY,
                                    PRBool aIgnoreRootScrollFrame,
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -611,19 +611,21 @@ GK_ATOM(object, "object")
 GK_ATOM(objectType, "object-type")
 GK_ATOM(observer, "observer")
 GK_ATOM(observes, "observes")
 GK_ATOM(odd, "odd")
 GK_ATOM(OFF, "OFF")
 GK_ATOM(ol, "ol")
 GK_ATOM(omitXmlDeclaration, "omit-xml-declaration")
 GK_ATOM(onabort, "onabort")
+GK_ATOM(onafterscriptexecute, "onafterscriptexecute")
 GK_ATOM(onbeforecopy, "onbeforecopy")
 GK_ATOM(onbeforecut, "onbeforecut")
 GK_ATOM(onbeforepaste, "onbeforepaste")
+GK_ATOM(onbeforescriptexecute, "onbeforescriptexecute")
 GK_ATOM(onbeforeunload, "onbeforeunload")
 GK_ATOM(onblur, "onblur")
 GK_ATOM(onbroadcast, "onbroadcast")
 GK_ATOM(onchange, "onchange")
 GK_ATOM(onclick, "onclick")
 GK_ATOM(onclose, "onclose")
 GK_ATOM(oncommand, "oncommand")
 GK_ATOM(oncommandupdate, "oncommandupdate")
--- a/content/base/src/nsScriptLoader.cpp
+++ b/content/base/src/nsScriptLoader.cpp
@@ -665,25 +665,45 @@ nsScriptLoader::ProcessRequest(nsScriptL
     script = &aRequest->mScriptText;
 
     nsCOMPtr<nsIContent> eltAsContent = do_QueryInterface(aRequest->mElement);
     NS_ASSERTION(eltAsContent, "Script should QI to nsIContent.");
     doc = eltAsContent->GetOwnerDoc();
   }
 
   FireScriptAvailable(NS_OK, aRequest);
-  aRequest->mElement->BeginEvaluating();
-  if (doc) {
-    doc->BeginEvaluatingExternalScript();
+
+  nsCOMPtr<nsINode> scriptElem = do_QueryInterface(aRequest->mElement);
+  PRBool runScript = PR_TRUE;
+  nsContentUtils::DispatchTrustedEvent(scriptElem->GetOwnerDoc(),
+                                       scriptElem,
+                                       NS_LITERAL_STRING("beforescriptexecute"),
+                                       PR_TRUE, PR_TRUE, &runScript);
+
+  nsresult rv = NS_OK;
+  if (runScript) {
+    aRequest->mElement->BeginEvaluating();
+    if (doc) {
+      doc->BeginEvaluatingExternalScript();
+    }
+    rv = EvaluateScript(aRequest, *script);
+    if (doc) {
+      doc->EndEvaluatingExternalScript();
+    }
+    aRequest->mElement->EndEvaluating();
+
+    nsContentUtils::DispatchTrustedEvent(scriptElem->GetOwnerDoc(),
+                                         scriptElem,
+                                         NS_LITERAL_STRING("afterscriptexecute"),
+                                         PR_TRUE, PR_FALSE);
   }
-  nsresult rv = EvaluateScript(aRequest, *script);
-  if (doc) {
-    doc->EndEvaluatingExternalScript();
+  else {
+    rv = NS_ERROR_ABORT;
   }
-  aRequest->mElement->EndEvaluating();
+
   FireScriptEvaluated(rv, aRequest);
 
   return rv;
 }
 
 void
 nsScriptLoader::FireScriptAvailable(nsresult aResult,
                                     nsScriptLoadRequest* aRequest)
--- a/content/base/test/Makefile.in
+++ b/content/base/test/Makefile.in
@@ -254,16 +254,17 @@ include $(topsrcdir)/config/rules.mk
 		file_bug590812-ref.xhtml \
 		test_bug368972.html \
 		test_bug448993.html \
 		test_bug450160.html \
 		test_bug453736.html \
 		test_bug454326.html \
 		test_bug505783.html \
 		test_bug457746.html \
+		test_bug587931.html \
 		test_bug518104.html \
 		bug457746.sjs \
 		test_CrossSiteXHR.html \
 		test_CrossSiteXHR_origin.html \
 		file_CrossSiteXHR_inner.html \
 		file_CrossSiteXHR_inner_data.sjs \
 		file_CrossSiteXHR_inner.jar \
 		file_CrossSiteXHR_server.sjs \
new file mode 100644
--- /dev/null
+++ b/content/base/test/test_bug587931.html
@@ -0,0 +1,94 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=587931
+-->
+<head>
+  <title>Test for Bug 587931</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=587931">Mozilla Bug 587931</a>
+<pre id="test">
+<script type="application/javascript">
+/** Test for Bug 587931 **/
+SimpleTest.waitForExplicitFinish();
+var afterCount = 0;
+var lastBeforeExecute = null;
+var expectedCurrentScriptInAfterScriptExecute = null;
+function verifyScript(n) {
+  var curr = document.currentScript;
+  is(curr, document.getElementById(n), "correct script (" + n + ")");
+  is(lastBeforeExecute, curr, "correct beforescript (" + n + ")");
+  document.addEventListener("afterscriptexecute", function(event) {
+    afterCount++;
+    lastBeforeExecute = null;
+    is(event.target, curr, "correct afterscript (" + n + ")");
+    is(document.currentScript, expectedCurrentScriptInAfterScriptExecute,
+       "document.currentScript in afterscriptexecute(" + n + ")");
+    document.removeEventListener("afterscriptexecute", arguments.callee, false);
+  }, false);
+}
+document.onbeforescriptexecute = function(event) {
+  lastBeforeExecute = event.target;
+};
+
+window.addEventListener("load", function() {
+  is(afterCount, 4, "correct number of afterscriptexecute");
+  SimpleTest.finish();
+}, false);
+</script>
+</pre>
+<!-- Test parser inserted scripts -->
+<script id="parse-inline">
+verifyScript("parse-inline");
+</script>
+<script id="parse-ext" src="data:text/plain,verifyScript('parse-ext');"></script>
+
+<!-- Test DOM inserted scripts -->
+<script>
+var s = document.createElement("script");
+s.textContent = "verifyScript('dom-inline');";
+s.id = "dom-inline";
+expectedCurrentScriptInAfterScriptExecute = document.currentScript;
+document.body.appendChild(s);
+expectedCurrentScriptInAfterScriptExecute = null;
+
+s = document.createElement("script");
+s.src = "data:text/plain,verifyScript('dom-ext');";
+s.id = "dom-ext";
+document.body.appendChild(s);
+</script>
+
+<!-- Test cancel using beforescriptexecute -->
+<script onbeforescriptexecute="return false;"
+        onafterescriptexecute="window.firedAfterScriptExecuteForCancel = true;"
+        onload="window.firedLoadForCancel = true;">
+ok(false, "should have been canceled");
+</script>
+<script>
+isnot(window.firedAfterScriptExecuteForCancel, true, "onafterscriptexecute executed");
+isnot(window.firedLoadForCancel, true, "onload executed");
+</script>
+
+<!-- Test that all events fire -->
+<script onbeforescriptexecute="window.beforeDidExecute = true;"
+        onafterscriptexecute="window.afterDidExecute = true;"
+        onload="window.loadDidExecute = true"
+        onerror="window.errorDidExecute = true"
+        src="data:text/plain,
+is(window.beforeDidExecute, true, 'onbeforescriptexecute executed');
+isnot(window.afterDidExecute, true, 'onafterscriptexecute executed');
+isnot(window.loadDidExecute, true, 'onload executed');
+isnot(window.errorDidExecute, true, 'onerror executed');
+">
+</script>
+<script>
+is(afterDidExecute, true, "onafterscriptexecute executed");
+is(loadDidExecute, true, "onload executed");
+isnot(window.errorDidExecute, true, "onerror executed");
+</script>
+</body>
+</html>
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -58,17 +58,18 @@
 #include "nsIURI.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIScriptError.h"
 #include "nsDOMPopStateEvent.h"
 
 static const char* const sEventNames[] = {
   "mousedown", "mouseup", "click", "dblclick", "mouseover",
   "mouseout", "MozMouseHittest", "mousemove", "contextmenu", "keydown", "keyup", "keypress",
-  "focus", "blur", "load", "popstate", "beforeunload", "unload",
+  "focus", "blur", "load", "popstate", "beforescriptexecute",
+  "afterscriptexecute", "beforeunload", "unload",
   "hashchange", "readystatechange", "abort", "error",
   "submit", "reset", "change", "select", "input", "invalid", "text",
   "compositionstart", "compositionend", "popupshowing", "popupshown",
   "popuphiding", "popuphidden", "close", "command", "broadcast", "commandupdate",
   "dragenter", "dragover", "dragexit", "dragdrop", "draggesture",
   "drag", "dragend", "dragstart", "dragleave", "drop", "resize",
   "scroll", "overflow", "underflow", "overflowchanged",
   "DOMSubtreeModified", "DOMNodeInserted", "DOMNodeRemoved", 
@@ -1122,16 +1123,20 @@ const char* nsDOMEvent::GetEventName(PRU
   case NS_BLUR_CONTENT:
     return sEventNames[eDOMEvents_blur];
   case NS_XUL_CLOSE:
     return sEventNames[eDOMEvents_close];
   case NS_LOAD:
     return sEventNames[eDOMEvents_load];
   case NS_POPSTATE:
     return sEventNames[eDOMEvents_popstate];
+  case NS_BEFORE_SCRIPT_EXECUTE:
+    return sEventNames[eDOMEvents_beforescriptexecute];
+  case NS_AFTER_SCRIPT_EXECUTE:
+    return sEventNames[eDOMEvents_afterscriptexecute];
   case NS_BEFORE_PAGE_UNLOAD:
     return sEventNames[eDOMEvents_beforeunload];
   case NS_PAGE_UNLOAD:
     return sEventNames[eDOMEvents_unload];
   case NS_HASHCHANGE:
     return sEventNames[eDOMEvents_hashchange];
   case NS_READYSTATECHANGE:
     return sEventNames[eDOMEvents_readystatechange];
--- a/content/events/src/nsDOMEvent.h
+++ b/content/events/src/nsDOMEvent.h
@@ -72,16 +72,18 @@ public:
     eDOMEvents_contextmenu,
     eDOMEvents_keydown,
     eDOMEvents_keyup,
     eDOMEvents_keypress,
     eDOMEvents_focus,
     eDOMEvents_blur,
     eDOMEvents_load,
     eDOMEvents_popstate,
+    eDOMEvents_beforescriptexecute,
+    eDOMEvents_afterscriptexecute,
     eDOMEvents_beforeunload,
     eDOMEvents_unload,
     eDOMEvents_hashchange,
     eDOMEvents_readystatechange,
     eDOMEvents_abort,
     eDOMEvents_error,
     eDOMEvents_submit,
     eDOMEvents_reset,
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -1629,16 +1629,18 @@ jsid nsDOMClassInfo::sOncanplaythrough_i
 jsid nsDOMClassInfo::sOnseeking_id       = JSID_VOID;
 jsid nsDOMClassInfo::sOnseeked_id        = JSID_VOID;
 jsid nsDOMClassInfo::sOntimeupdate_id    = JSID_VOID;
 jsid nsDOMClassInfo::sOnended_id         = JSID_VOID;
 jsid nsDOMClassInfo::sOnratechange_id    = JSID_VOID;
 jsid nsDOMClassInfo::sOndurationchange_id= JSID_VOID;
 jsid nsDOMClassInfo::sOnvolumechange_id  = JSID_VOID;
 jsid nsDOMClassInfo::sOnmessage_id       = JSID_VOID;
+jsid nsDOMClassInfo::sOnbeforescriptexecute_id = JSID_VOID;
+jsid nsDOMClassInfo::sOnafterscriptexecute_id = JSID_VOID;
 
 static const JSClass *sObjectClass = nsnull;
 JSPropertyOp nsDOMClassInfo::sXPCNativeWrapperGetPropertyOp = nsnull;
 JSPropertyOp nsDOMClassInfo::sXrayWrapperPropertyHolderGetPropertyOp = nsnull;
 
 /**
  * Set our JSClass pointer for the Object class
  */
@@ -1853,16 +1855,18 @@ nsDOMClassInfo::DefineStaticJSVals(JSCon
   SET_JSID_TO_STRING(sOnseeking_id,       cx, "onseeking");
   SET_JSID_TO_STRING(sOnseeked_id,        cx, "onseeked");
   SET_JSID_TO_STRING(sOntimeupdate_id,    cx, "ontimeupdate");
   SET_JSID_TO_STRING(sOnended_id,         cx, "onended");
   SET_JSID_TO_STRING(sOnratechange_id,    cx, "onratechange");
   SET_JSID_TO_STRING(sOndurationchange_id,cx, "ondurationchange");
   SET_JSID_TO_STRING(sOnvolumechange_id,  cx, "onvolumechange");
   SET_JSID_TO_STRING(sOnmessage_id,       cx, "onmessage");
+  SET_JSID_TO_STRING(sOnbeforescriptexecute_id, cx, "onbeforescriptexecute");
+  SET_JSID_TO_STRING(sOnafterscriptexecute_id, cx, "onafterscriptexecute");
 #endif // MOZ_MEDIA
 
   return NS_OK;
 }
 
 static nsresult
 CreateExceptionFromResult(JSContext *cx, nsresult aResult)
 {
@@ -4926,16 +4930,18 @@ nsDOMClassInfo::ShutDown()
   sOnseeking_id       = JSID_VOID;
   sOnseeked_id        = JSID_VOID;
   sOntimeupdate_id    = JSID_VOID;
   sOnended_id         = JSID_VOID;
   sOnratechange_id    = JSID_VOID;
   sOndurationchange_id= JSID_VOID;
   sOnvolumechange_id  = JSID_VOID;
   sOnmessage_id       = JSID_VOID;
+  sOnbeforescriptexecute_id = JSID_VOID;
+  sOnafterscriptexecute_id = JSID_VOID;
 
   NS_IF_RELEASE(sXPConnect);
   NS_IF_RELEASE(sSecMan);
   sIsInitialized = PR_FALSE;
 }
 
 // Window helper
 
@@ -7731,19 +7737,21 @@ nsNodeSH::PreserveWrapper(nsISupports *a
 // static
 PRBool
 nsEventReceiverSH::ReallyIsEventName(jsid id, jschar aFirstChar)
 {
   // I wonder if this is faster than using a hash...
 
   switch (aFirstChar) {
   case 'a' :
-    return id == sOnabort_id;
+    return (id == sOnabort_id ||
+            id == sOnafterscriptexecute_id);
   case 'b' :
     return (id == sOnbeforeunload_id ||
+            id == sOnbeforescriptexecute_id ||
             id == sOnblur_id);
   case 'c' :
     return (id == sOnchange_id       ||
             id == sOnclick_id        ||
             id == sOncontextmenu_id  ||
             id == sOncopy_id         ||
             id == sOncut_id          ||
             id == sOncanplay_id      ||
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -376,16 +376,18 @@ protected:
   static jsid sOnseeking_id;
   static jsid sOnseeked_id;
   static jsid sOntimeupdate_id;
   static jsid sOnended_id;
   static jsid sOnratechange_id;
   static jsid sOndurationchange_id;
   static jsid sOnvolumechange_id;
   static jsid sOnmessage_id;
+  static jsid sOnbeforescriptexecute_id;
+  static jsid sOnafterscriptexecute_id;
 
   static JSPropertyOp sXPCNativeWrapperGetPropertyOp;
   static JSPropertyOp sXrayWrapperPropertyHolderGetPropertyOp;
 };
 
 
 inline
 const nsQueryInterface
--- a/dom/interfaces/core/nsIDOMNSDocument.idl
+++ b/dom/interfaces/core/nsIDOMNSDocument.idl
@@ -38,17 +38,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "domstubs.idl"
 
 interface nsIBoxObject;
 interface nsIDOMLocation;
 
-[scriptable, uuid(7485b35e-d215-42a0-8a67-896f86c8afd9)]
+[scriptable, uuid(92f2c6f8-3668-4a47-8251-2a900afe11fa)]
 interface nsIDOMNSDocument : nsISupports
 {
   readonly attribute DOMString      characterSet;
            attribute DOMString      dir;
 
   readonly attribute nsIDOMLocation location;
 
            attribute DOMString      title;
@@ -57,16 +57,18 @@ interface nsIDOMNSDocument : nsISupports
   readonly attribute DOMString      readyState;
   readonly attribute DOMString      lastModified;
   readonly attribute DOMString      referrer;
 
   boolean      hasFocus();
 
   readonly attribute nsIDOMElement  activeElement;
 
+  readonly attribute nsIDOMElement  currentScript;
+
   /*
    * Retrieve elements matching all classes listed in a
    * space-separated string.
    *
    * See <http://whatwg.org/specs/web-apps/current-work/>
    */
   nsIDOMNodeList getElementsByClassName(in DOMString classes);
 
--- a/widget/public/nsGUIEvent.h
+++ b/widget/public/nsGUIEvent.h
@@ -483,16 +483,21 @@ class nsHashKey;
 #define NS_SMIL_REPEAT               (NS_SMIL_TIME_EVENT_START + 2)
 #endif // MOZ_SMIL
 
 #define NS_MOZTOUCH_EVENT_START      4400
 #define NS_MOZTOUCH_DOWN             (NS_MOZTOUCH_EVENT_START)
 #define NS_MOZTOUCH_MOVE             (NS_MOZTOUCH_EVENT_START+1)
 #define NS_MOZTOUCH_UP               (NS_MOZTOUCH_EVENT_START+2)
 
+// script notification events
+#define NS_NOTIFYSCRIPT_START    4500
+#define NS_BEFORE_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START)
+#define NS_AFTER_SCRIPT_EXECUTE  (NS_NOTIFYSCRIPT_START+1)
+
 /**
  * Return status for event processors, nsEventStatus, is defined in
  * nsEvent.h.
  */
 
 /**
  * different types of (top-level) window z-level positioning
  */
--- a/widget/src/xpwidgets/nsBaseWidget.cpp
+++ b/widget/src/xpwidgets/nsBaseWidget.cpp
@@ -1197,16 +1197,18 @@ case _value: eventName.AssignWithConvers
     _ASSIGN_eventName(NS_MOUSE_BUTTON_DOWN,"NS_MOUSE_BUTTON_DOWN");
     _ASSIGN_eventName(NS_MOUSE_BUTTON_UP,"NS_MOUSE_BUTTON_UP");
     _ASSIGN_eventName(NS_MOUSE_CLICK,"NS_MOUSE_CLICK");
     _ASSIGN_eventName(NS_MOUSE_DOUBLECLICK,"NS_MOUSE_DBLCLICK");
     _ASSIGN_eventName(NS_MOUSE_MOVE,"NS_MOUSE_MOVE");
     _ASSIGN_eventName(NS_MOVE,"NS_MOVE");
     _ASSIGN_eventName(NS_LOAD,"NS_LOAD");
     _ASSIGN_eventName(NS_POPSTATE,"NS_POPSTATE");
+    _ASSIGN_eventName(NS_BEFORE_SCRIPT_EXECUTE,"NS_BEFORE_SCRIPT_EXECUTE");
+    _ASSIGN_eventName(NS_AFTER_SCRIPT_EXECUTE,"NS_AFTER_SCRIPT_EXECUTE");
     _ASSIGN_eventName(NS_PAGE_UNLOAD,"NS_PAGE_UNLOAD");
     _ASSIGN_eventName(NS_HASHCHANGE,"NS_HASHCHANGE");
     _ASSIGN_eventName(NS_READYSTATECHANGE,"NS_READYSTATECHANGE");
     _ASSIGN_eventName(NS_PAINT,"NS_PAINT");
     _ASSIGN_eventName(NS_XUL_BROADCAST, "NS_XUL_BROADCAST");
     _ASSIGN_eventName(NS_XUL_COMMAND_UPDATE, "NS_XUL_COMMAND_UPDATE");
     _ASSIGN_eventName(NS_SCROLLBAR_LINE_NEXT,"NS_SB_LINE_NEXT");
     _ASSIGN_eventName(NS_SCROLLBAR_LINE_PREV,"NS_SB_LINE_PREV");