Bug 682554. Move onreadystatechange to live on Document only. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 19 Sep 2011 22:56:45 -0400
changeset 78484 2dbed30dd67d46cd929a305842938a2cf95f7231
parent 78483 30a5dfdf8aba3543e6974d1650423c9b88892b62
child 78485 1cb463c1c7b78de8103d36c01d5e6ed40efee6cd
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs682554
milestone9.0a1
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 682554. Move onreadystatechange to live on Document only. r=smaug
content/base/public/nsINode.h
content/base/src/nsDocument.cpp
content/base/src/nsGenericElement.cpp
content/base/test/Makefile.in
content/base/test/test_bug682554.html
content/events/public/nsEventNameList.h
dom/interfaces/core/nsIDOMDocument.idl
dom/interfaces/core/nsIDOMXMLDocument.idl
dom/interfaces/core/nsIInlineEventHandlers.idl
dom/interfaces/html/nsIDOMHTMLDocument.idl
dom/interfaces/svg/nsIDOMSVGDocument.idl
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -1350,22 +1350,28 @@ protected:
    * @param aChildArray The child array to work with
    */
   nsresult doInsertChildAt(nsIContent* aKid, PRUint32 aIndex,
                            PRBool aNotify, nsAttrAndChildArray& aChildArray);
 
   /* Event stuff that documents and elements share.  This needs to be
      NS_IMETHOD because some subclasses implement DOM methods with
      this exact name and signature and then the calling convention
-     needs to match. */
+     needs to match.
+
+     Note that we include DOCUMENT_ONLY_EVENT events here so that we
+     can forward all the document stuff to this implementation.
+  */
 #define EVENT(name_, id_, type_, struct_)                         \
   NS_IMETHOD GetOn##name_(JSContext *cx, jsval *vp);              \
   NS_IMETHOD SetOn##name_(JSContext *cx, const jsval &v);
 #define TOUCH_EVENT EVENT
+#define DOCUMENT_ONLY_EVENT EVENT
 #include "nsEventNameList.h"
+#undef DOCUMENT_ONLY_EVENT
 #undef TOUCH_EVENT
 #undef EVENT  
 
   static void Trace(nsINode *tmp, TraceCallback cb, void *closure);
   static bool Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb);
   static void Unlink(nsINode *tmp);
 
   nsCOMPtr<nsINodeInfo> mNodeInfo;
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -8683,11 +8683,13 @@ nsDocument::SizeOf() const
 #define EVENT(name_, id_, type_, struct_)                                 \
   NS_IMETHODIMP nsDocument::GetOn##name_(JSContext *cx, jsval *vp) {      \
     return nsINode::GetOn##name_(cx, vp);                                 \
   }                                                                       \
   NS_IMETHODIMP nsDocument::SetOn##name_(JSContext *cx, const jsval &v) { \
     return nsINode::SetOn##name_(cx, v);                                  \
   }
 #define TOUCH_EVENT EVENT
+#define DOCUMENT_ONLY_EVENT EVENT
 #include "nsEventNameList.h"
+#undef DOCUMENT_ONLY_EVENT
 #undef TOUCH_EVENT
 #undef EVENT
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -5522,17 +5522,19 @@ nsGenericElement::SizeOf() const
     JSObject *obj = GetWrapper();                                            \
     if (!obj) {                                                              \
       /* Just silently do nothing */                                         \
       return NS_OK;                                                          \
     }                                                                        \
     return elm->SetJSEventListenerToJsval(nsGkAtoms::on##name_, cx, obj, v); \
 }
 #define TOUCH_EVENT EVENT
+#define DOCUMENT_ONLY_EVENT EVENT
 #include "nsEventNameList.h"
+#undef DOCUMENT_ONLY_EVENT
 #undef TOUCH_EVENT
 #undef EVENT
 
 PRBool
 nsINode::Contains(const nsINode* aOther) const
 {
   if (aOther == this) {
     return PR_TRUE;
--- a/content/base/test/Makefile.in
+++ b/content/base/test/Makefile.in
@@ -502,16 +502,17 @@ include $(topsrcdir)/config/rules.mk
 		somedatas.resource^headers^ \
 		delayedServerEvents.sjs \
 		test_bug664916.html \
 		test_bug666604.html \
 		test_bug675121.html \
 		file_bug675121.sjs \
 		test_bug654352.html \
 		test_bug675166.html \
+		test_bug682554.html \
 		test_bug682592.html \
 		bug682592-subframe.html \
 		bug682592-subframe-ref.html \
 		test_bug685798.html \
 		$(NULL)
 
 _CHROME_FILES =	\
 		test_bug357450.js \
new file mode 100644
--- /dev/null
+++ b/content/base/test/test_bug682554.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=682554
+-->
+<head>
+  <title>Test for Bug 682554</title>
+  <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=682554">Mozilla Bug 682554</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 682554 **/
+is("onreadystatechange" in window, false,
+   "Window should not have an onreadystatechange");
+is("onreadystatechange" in document, true,
+   "Document should have an onreadystatechange");
+is("onreadystatechange" in document.createElement("script"), false,
+   "<script> element should not have an onreadystatechange");
+</script>
+</pre>
+</body>
+</html>
--- a/content/events/public/nsEventNameList.h
+++ b/content/events/public/nsEventNameList.h
@@ -66,16 +66,20 @@
  * exposed as IDL attributes on the Window should be enclosed in the
  * WINDOW_EVENT macro.  If this macro is not defined, it will be
  * defined to be equivalent to WINDOW_ONLY_EVENT.
  *
  * Touch-specific event names should be enclosed in TOUCH_EVENT.  They
  * are otherwise equivalent to those enclosed in EVENT.  If
  * TOUCH_EVENT is not defined, it will be defined to the empty string.
  *
+ * Event names that are only exposed as IDL attributes on Documents
+ * should be enclosed in the DOCUMENT_ONLY_EVENT macro.  If this macro is
+ * not defined, it will be defined to the empty string.
+ *
  * Event names that are not exposed as IDL attributes at all should be
  * enclosed in NON_IDL_EVENT.  If NON_IDL_EVENT is not defined, it
  * will be defined to the empty string.
  */
 
 #ifdef DEFINED_FORWARDED_EVENT
 #error "Don't define DEFINED_FORWARDED_EVENT"
 #endif /* DEFINED_FORWARDED_EVENT */
@@ -107,16 +111,25 @@
 #error "Don't define DEFINED_TOUCH_EVENT"
 #endif /* DEFINED_TOUCH_EVENT */
 
 #ifndef TOUCH_EVENT
 #define TOUCH_EVENT(_name, _id, _type, _struct)
 #define DEFINED_TOUCH_EVENT
 #endif /* TOUCH_EVENT */
 
+#ifdef DEFINED_DOCUMENT_ONLY_EVENT
+#error "Don't define DEFINED_DOCUMENT_ONLY_EVENT"
+#endif /* DEFINED_DOCUMENT_ONLY_EVENT */
+
+#ifndef DOCUMENT_ONLY_EVENT
+#define DOCUMENT_ONLY_EVENT(_name, _id, _type, _struct)
+#define DEFINED_DOCUMENT_ONLY_EVENT
+#endif /* DOCUMENT_ONLY_EVENT */
+
 #ifdef DEFINED_NON_IDL_EVENT
 #error "Don't define DEFINED_NON_IDL_EVENT"
 #endif /* DEFINED_NON_IDL_EVENT */
 
 #ifndef NON_IDL_EVENT
 #define NON_IDL_EVENT(_name, _id, _type, _struct)
 #define DEFINED_NON_IDL_EVENT
 #endif /* NON_IDL_EVENT */
@@ -272,20 +285,16 @@ EVENT(playing,
 EVENT(progress,
       NS_PROGRESS,
       EventNameType_HTML,
       NS_EVENT_NULL)
 EVENT(ratechange,
       NS_RATECHANGE,
       EventNameType_HTML,
       NS_EVENT_NULL)
-EVENT(readystatechange,
-      NS_READYSTATECHANGE,
-      EventNameType_HTMLXUL,
-      NS_EVENT_NULL)
 EVENT(reset,
       NS_FORM_RESET,
       EventNameType_HTMLXUL,
       NS_EVENT)
 EVENT(seeked,
       NS_SEEKED,
       EventNameType_HTML,
       NS_EVENT_NULL)
@@ -452,16 +461,21 @@ TOUCH_EVENT(touchleave,
             NS_USER_DEFINED_EVENT,
             EventNameType_All,
             NS_INPUT_EVENT)
 TOUCH_EVENT(touchcancel,
             NS_USER_DEFINED_EVENT,
             EventNameType_All,
             NS_INPUT_EVENT)
 
+DOCUMENT_ONLY_EVENT(readystatechange,
+                    NS_READYSTATECHANGE,
+                    EventNameType_HTMLXUL,
+                    NS_EVENT_NULL)
+
 NON_IDL_EVENT(MozMouseHittest,
               NS_MOUSE_MOZHITTEST,
               EventNameType_None,
               NS_MOUSE_EVENT)
 
 NON_IDL_EVENT(DOMAttrModified,
               NS_MUTATION_ATTRMODIFIED,
               EventNameType_HTMLXUL,
@@ -751,13 +765,18 @@ NON_IDL_EVENT(animationiteration,
 #undef WINDOW_ONLY_EVENT
 #endif /* DEFINED_WINDOW_ONLY_EVENT */
 
 #ifdef DEFINED_TOUCH_EVENT
 #undef DEFINED_TOUCH_EVENT
 #undef TOUCH_EVENT
 #endif /* DEFINED_TOUCH_EVENT */
 
+#ifdef DEFINED_DOCUMENT_ONLY_EVENT
+#undef DEFINED_DOCUMENT_ONLY_EVENT
+#undef DOCUMENT_ONLY_EVENT
+#endif /* DEFINED_DOCUMENT_ONLY_EVENT */
+
 #ifdef DEFINED_NON_IDL_EVENT
 #undef DEFINED_NON_IDL_EVENT
 #undef NON_IDL_EVENT
 #endif /* DEFINED_NON_IDL_EVENT */
 
--- a/dom/interfaces/core/nsIDOMDocument.idl
+++ b/dom/interfaces/core/nsIDOMDocument.idl
@@ -39,16 +39,20 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIDOMNode.idl"
 
+%{ C++
+#include "jspubtd.h"
+%}
+
 interface nsIDOMNodeIterator;
 interface nsIDOMNodeFilter;
 interface nsIDOMTreeWalker;
 interface nsIDOMLocation;
 interface nsIDOMCaretPosition;
 
 /**
  * The nsIDOMDocument interface represents the entire HTML or XML document.
@@ -58,17 +62,17 @@ interface nsIDOMCaretPosition;
  * cannot exist outside the context of a Document, the nsIDOMDocument 
  * interface also contains the factory methods needed to create these 
  * objects.
  *
  * For more information on this interface please see 
  * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
  */
 
-[scriptable, uuid(48ef69c6-844f-41ba-af66-17b338177a8b)]
+[scriptable, uuid(C54536AF-C238-4D8B-A339-54E2A0649FF5)]
 interface nsIDOMDocument : nsIDOMNode
 {
   readonly attribute nsIDOMDocumentType         doctype;
   readonly attribute nsIDOMDOMImplementation    implementation;
   readonly attribute nsIDOMElement              documentElement;
   nsIDOMElement                 createElement(in DOMString tagName)
                                   raises(DOMException);
   nsIDOMDocumentFragment        createDocumentFragment();
@@ -390,9 +394,14 @@ interface nsIDOMDocument : nsIDOMNode
   
   /**
    * Denotes whether this document is in DOM full-screen mode, as per the DOM
    * full-screen api.
    *
    * @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI>
    */
   readonly attribute boolean mozFullScreen;  
+
+  /**
+   * Inline event handler for readystatechange events.
+   */
+  [implicit_jscontext] attribute jsval onreadystatechange;
 };
--- a/dom/interfaces/core/nsIDOMXMLDocument.idl
+++ b/dom/interfaces/core/nsIDOMXMLDocument.idl
@@ -33,17 +33,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIDOMDocument.idl"
 
-[scriptable, uuid(e788e37b-9a89-4b3e-9593-c598e50695eb)]
+[scriptable, uuid(0457526E-1FA5-476C-9314-0F704617B9F4)]
 interface nsIDOMXMLDocument : nsIDOMDocument
 {
   // DOM Level 3 Load & Save, DocumentLS
   // http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS
   /**
    * Whether to load synchronously or asynchronously.
    * The default is async==true.
    */
--- a/dom/interfaces/core/nsIInlineEventHandlers.idl
+++ b/dom/interfaces/core/nsIInlineEventHandlers.idl
@@ -34,17 +34,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 #include "domstubs.idl"
 
 %{ C++
 #include "jspubtd.h"
 %}
 
-[scriptable, uuid(790ad9f7-167a-4f5f-a5c1-8cfb3697104d)]
+[scriptable, uuid(1b065b41-6e00-450c-a44c-e0e44581c08a)]
 interface nsIInlineEventHandlers : nsISupports
 {
   [implicit_jscontext] attribute jsval onabort;
   [implicit_jscontext] attribute jsval onblur;
   [implicit_jscontext] attribute jsval oncanplay;
   [implicit_jscontext] attribute jsval oncanplaythrough;
   [implicit_jscontext] attribute jsval onchange;
   [implicit_jscontext] attribute jsval onclick;
@@ -83,17 +83,16 @@ interface nsIInlineEventHandlers : nsISu
   // Not supported yet
   // [implicit_jscontext] attribute jsval onmousewheel;
   [implicit_jscontext] attribute jsval onmozfullscreenchange;
   [implicit_jscontext] attribute jsval onpause;
   [implicit_jscontext] attribute jsval onplay;
   [implicit_jscontext] attribute jsval onplaying;
   [implicit_jscontext] attribute jsval onprogress;
   [implicit_jscontext] attribute jsval onratechange;
-  [implicit_jscontext] attribute jsval onreadystatechange;
   [implicit_jscontext] attribute jsval onreset;
   [implicit_jscontext] attribute jsval onscroll;
   [implicit_jscontext] attribute jsval onseeked;
   [implicit_jscontext] attribute jsval onseeking;
   [implicit_jscontext] attribute jsval onselect;
   [implicit_jscontext] attribute jsval onshow;
   [implicit_jscontext] attribute jsval onstalled;
   [implicit_jscontext] attribute jsval onsubmit;
--- a/dom/interfaces/html/nsIDOMHTMLDocument.idl
+++ b/dom/interfaces/html/nsIDOMHTMLDocument.idl
@@ -42,17 +42,17 @@
 /**
  * The nsIDOMHTMLDocument interface is the interface to a [X]HTML
  * document object.
  *
  * @see <http://www.whatwg.org/html/>
  */
 interface nsISelection;
 
-[scriptable, uuid(7587ce39-e939-4b86-838d-a1d04e4e04c0)]
+[scriptable, uuid(DA6A8183-3C50-4F4A-9EFC-0E050B9A856A)]
 interface nsIDOMHTMLDocument : nsIDOMDocument
 {
   readonly attribute DOMString            URL;
            attribute DOMString            domain;
            attribute DOMString            cookie;
   // returns "BackCompat" if we're in quirks mode,
   // or "CSS1Compat" if we're in strict mode
   readonly attribute DOMString            compatMode;
--- a/dom/interfaces/svg/nsIDOMSVGDocument.idl
+++ b/dom/interfaces/svg/nsIDOMSVGDocument.idl
@@ -34,15 +34,15 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIDOMDocument.idl"
 
 interface nsIDOMSVGSVGElement;
 
-[scriptable, uuid(4ac55dee-ce7f-465d-a27c-ecc293ae35db)]
+[scriptable, uuid(E055EF40-D6BA-443A-B4DB-C1CCFAA6EB31)]
 interface nsIDOMSVGDocument : nsIDOMDocument
 {
   readonly attribute DOMString domain;
   readonly attribute DOMString URL;
   readonly attribute nsIDOMSVGSVGElement rootElement;
 };