Bug 795544 - Make StringEncoding API available from xpcshell/jsm. r=bz
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Tue, 02 Oct 2012 20:14:38 -0400
changeset 109068 1d4bafc6c4817a3e76d65219b6752fa02c8df247
parent 109067 6bcb5f9359d8cae3ee2f2d4ee452b13e3f093b35
child 109069 3afaf5133beca682a9e9700f150776ddbd4aeff0
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersbz
bugs795544
milestone18.0a1
Bug 795544 - Make StringEncoding API available from xpcshell/jsm. r=bz
js/xpconnect/src/nsXPConnect.cpp
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -29,16 +29,18 @@
 #ifdef MOZ_JSDEBUGGER
 #include "jsdIDebuggerService.h"
 #endif
 
 #include "XPCQuickStubs.h"
 #include "dombindings.h"
 
 #include "mozilla/dom/BindingUtils.h"
+#include "mozilla/dom/TextDecoderBinding.h"
+#include "mozilla/dom/TextEncoderBinding.h"
 
 #include "nsWrapperCacheInlines.h"
 #include "nsDOMMutationObserver.h"
 #include "nsICycleCollectorListener.h"
 
 using namespace mozilla::dom;
 using namespace xpc;
 
@@ -1181,16 +1183,22 @@ nsXPConnect::InitClassesWithNewWrappedGl
             return UnexpectedFailure(NS_ERROR_FAILURE);
     }
 
     // Stuff coming through this path always ends up as a DOM global.
     // XXX Someone who knows why we can assert this should re-check
     //     (after bug 720580).
     MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
 
+    // Init WebIDL binding constructors wanted on all XPConnect globals.
+    if (!TextDecoderBinding::GetProtoObject(aJSContext, global, global) ||
+        !TextEncoderBinding::GetProtoObject(aJSContext, global, global)) {
+        return UnexpectedFailure(NS_ERROR_FAILURE);
+    }
+
     wrappedGlobal.forget(_retval);
     return NS_OK;
 }
 
 nsresult
 xpc_MorphSlimWrapper(JSContext *cx, nsISupports *tomorph)
 {
     nsWrapperCache *cache;