diff --git a/content/base/public/nsContentErrors.h b/content/base/public/nsContentErrors.h index c46f50cf22cf..dfb1a4034814 100644 --- a/content/base/public/nsContentErrors.h +++ b/content/base/public/nsContentErrors.h @@ -73,4 +73,8 @@ #define NS_XML_AUTOLINK_UNDEFINED \ NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 7) +/** Error codes for nsIScriptLoader */ +#define NS_CONTENT_SCRIPT_IS_EVENTHANDLER \ + NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 8) + #endif // nsContentErrors_h___ diff --git a/content/base/src/nsScriptLoader.cpp b/content/base/src/nsScriptLoader.cpp index 4ee166182fcd..606d46c93f86 100644 --- a/content/base/src/nsScriptLoader.cpp +++ b/content/base/src/nsScriptLoader.cpp @@ -42,6 +42,8 @@ #include "nsIScriptElement.h" #include "nsIDocShell.h" #include "jsapi.h" +#include "nsContentUtils.h" +#include "nsUnicharUtils.h" static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID); @@ -234,6 +236,72 @@ nsScriptLoader::InNonScriptingContainer(nsIDOMHTMLScriptElement* aScriptElement) return PR_FALSE; } +// Helper method for checking if the script element is an event-handler +// This means that it has both a for-attribute and a event-attribute. +// Also, if the for-attribute has a value that matches "\s*window\s*", +// and the event-attribute matches "\s*onload([ \(].*)?" then it isn't an +// eventhandler. (both matches are case insensitive). +// This is how IE seems to filter out a window's onload handler from a +//