Bug 864727 part 5. Make all the WrapObject methods take a handle for the scope object. r=ms2ger
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 25 Apr 2013 12:29:54 -0400
changeset 136666 1b1381894c4402d105cf59e45078bd9573facd01
parent 136665 3011f288bfe7da7bafa1f52853341cfd5dd7fdc1
child 136667 e98c80465618bd9b0919e103d93a22d259376a13
push id3752
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 17:21:10 +0000
treeherdermozilla-aurora@1580544aef0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersms2ger
bugs864727
milestone23.0a1
Bug 864727 part 5. Make all the WrapObject methods take a handle for the scope object. r=ms2ger
content/base/public/Element.h
content/base/public/FragmentOrElement.h
content/base/public/nsDOMFile.h
content/base/public/nsINode.h
content/base/src/Attr.cpp
content/base/src/Attr.h
content/base/src/DOMImplementation.cpp
content/base/src/DOMImplementation.h
content/base/src/Element.cpp
content/base/src/EventSource.cpp
content/base/src/EventSource.h
content/base/src/FragmentOrElement.cpp
content/base/src/NodeIterator.cpp
content/base/src/NodeIterator.h
content/base/src/TreeWalker.cpp
content/base/src/TreeWalker.h
content/base/src/WebSocket.cpp
content/base/src/WebSocket.h
content/base/src/nsContentList.cpp
content/base/src/nsContentList.h
content/base/src/nsDOMCaretPosition.cpp
content/base/src/nsDOMCaretPosition.h
content/base/src/nsDOMFile.cpp
content/base/src/nsDOMFileReader.cpp
content/base/src/nsDOMFileReader.h
content/base/src/nsDOMMutationObserver.h
content/base/src/nsDOMParser.h
content/base/src/nsDOMSerializer.h
content/base/src/nsDOMSettableTokenList.cpp
content/base/src/nsDOMSettableTokenList.h
content/base/src/nsDOMTokenList.cpp
content/base/src/nsDOMTokenList.h
content/base/src/nsFormData.cpp
content/base/src/nsFormData.h
content/base/src/nsINode.cpp
content/base/src/nsRange.cpp
content/base/src/nsRange.h
content/base/src/nsXMLHttpRequest.h
content/canvas/src/CanvasRenderingContext2D.cpp
content/canvas/src/CanvasRenderingContext2D.h
content/canvas/src/ImageData.cpp
content/canvas/src/ImageData.h
content/canvas/src/TextMetrics.h
content/canvas/src/WebGLActiveInfo.cpp
content/canvas/src/WebGLBuffer.cpp
content/canvas/src/WebGLBuffer.h
content/canvas/src/WebGLContext.cpp
content/canvas/src/WebGLContext.h
content/canvas/src/WebGLExtensions.h
content/canvas/src/WebGLFramebuffer.cpp
content/canvas/src/WebGLFramebuffer.h
content/canvas/src/WebGLProgram.cpp
content/canvas/src/WebGLProgram.h
content/canvas/src/WebGLRenderbuffer.cpp
content/canvas/src/WebGLRenderbuffer.h
content/canvas/src/WebGLShader.cpp
content/canvas/src/WebGLShader.h
content/canvas/src/WebGLShaderPrecisionFormat.cpp
content/canvas/src/WebGLShaderPrecisionFormat.h
content/canvas/src/WebGLTexture.cpp
content/canvas/src/WebGLTexture.h
content/canvas/src/WebGLUniformLocation.cpp
content/canvas/src/WebGLUniformLocation.h
content/events/src/DOMWheelEvent.h
content/events/src/Touch.cpp
content/events/src/Touch.h
content/events/src/nsDOMAnimationEvent.h
content/events/src/nsDOMBeforeUnloadEvent.h
content/events/src/nsDOMClipboardEvent.h
content/events/src/nsDOMCommandEvent.h
content/events/src/nsDOMCompositionEvent.h
content/events/src/nsDOMDeviceMotionEvent.h
content/events/src/nsDOMDragEvent.h
content/events/src/nsDOMEvent.h
content/events/src/nsDOMGamepad.cpp
content/events/src/nsDOMGamepad.h
content/events/src/nsDOMKeyboardEvent.h
content/events/src/nsDOMMessageEvent.h
content/events/src/nsDOMMouseEvent.h
content/events/src/nsDOMMouseScrollEvent.h
content/events/src/nsDOMMutationEvent.h
content/events/src/nsDOMNotifyPaintEvent.h
content/events/src/nsDOMScrollAreaEvent.h
content/events/src/nsDOMSimpleGestureEvent.h
content/events/src/nsDOMTouchEvent.h
content/events/src/nsDOMTransitionEvent.h
content/events/src/nsDOMUIEvent.h
content/events/src/nsDOMXULCommandEvent.h
content/events/src/nsPaintRequest.cpp
content/events/src/nsPaintRequest.h
content/html/content/public/nsIHTMLCollection.h
content/html/content/src/HTMLOptionsCollection.cpp
content/html/content/src/HTMLOptionsCollection.h
content/html/content/src/HTMLPropertiesCollection.cpp
content/html/content/src/HTMLPropertiesCollection.h
content/html/content/src/HTMLTableElement.cpp
content/html/content/src/MediaError.cpp
content/html/content/src/MediaError.h
content/html/content/src/TimeRanges.cpp
content/html/content/src/TimeRanges.h
content/html/content/src/UndoManager.h
content/html/content/src/ValidityState.cpp
content/html/content/src/ValidityState.h
content/html/content/src/nsClientRect.cpp
content/html/content/src/nsClientRect.h
content/html/content/src/nsDOMStringMap.cpp
content/html/content/src/nsDOMStringMap.h
content/html/content/src/nsHTMLFormElement.cpp
content/media/AudioStreamTrack.cpp
content/media/AudioStreamTrack.h
content/media/DOMMediaStream.cpp
content/media/DOMMediaStream.h
content/media/MediaStreamTrack.h
content/media/VideoStreamTrack.cpp
content/media/VideoStreamTrack.h
content/media/webaudio/AnalyserNode.cpp
content/media/webaudio/AnalyserNode.h
content/media/webaudio/AudioBuffer.cpp
content/media/webaudio/AudioBuffer.h
content/media/webaudio/AudioBufferSourceNode.cpp
content/media/webaudio/AudioBufferSourceNode.h
content/media/webaudio/AudioContext.cpp
content/media/webaudio/AudioContext.h
content/media/webaudio/AudioDestinationNode.cpp
content/media/webaudio/AudioDestinationNode.h
content/media/webaudio/AudioListener.cpp
content/media/webaudio/AudioListener.h
content/media/webaudio/AudioParam.cpp
content/media/webaudio/AudioParam.h
content/media/webaudio/AudioProcessingEvent.cpp
content/media/webaudio/AudioProcessingEvent.h
content/media/webaudio/BiquadFilterNode.cpp
content/media/webaudio/BiquadFilterNode.h
content/media/webaudio/DelayNode.cpp
content/media/webaudio/DelayNode.h
content/media/webaudio/DynamicsCompressorNode.cpp
content/media/webaudio/DynamicsCompressorNode.h
content/media/webaudio/GainNode.cpp
content/media/webaudio/GainNode.h
content/media/webaudio/PannerNode.cpp
content/media/webaudio/PannerNode.h
content/media/webaudio/ScriptProcessorNode.cpp
content/media/webaudio/ScriptProcessorNode.h
content/media/webspeech/recognition/SpeechGrammar.cpp
content/media/webspeech/recognition/SpeechGrammar.h
content/media/webspeech/recognition/SpeechGrammarList.cpp
content/media/webspeech/recognition/SpeechGrammarList.h
content/media/webspeech/recognition/SpeechRecognition.cpp
content/media/webspeech/recognition/SpeechRecognition.h
content/media/webspeech/recognition/SpeechRecognitionAlternative.cpp
content/media/webspeech/recognition/SpeechRecognitionAlternative.h
content/media/webspeech/recognition/SpeechRecognitionResult.cpp
content/media/webspeech/recognition/SpeechRecognitionResult.h
content/media/webspeech/recognition/SpeechRecognitionResultList.cpp
content/media/webspeech/recognition/SpeechRecognitionResultList.h
content/media/webspeech/synth/SpeechSynthesis.cpp
content/media/webspeech/synth/SpeechSynthesis.h
content/media/webspeech/synth/SpeechSynthesisUtterance.cpp
content/media/webspeech/synth/SpeechSynthesisUtterance.h
content/media/webspeech/synth/SpeechSynthesisVoice.cpp
content/media/webspeech/synth/SpeechSynthesisVoice.h
content/svg/content/src/DOMSVGAnimatedLengthList.cpp
content/svg/content/src/DOMSVGAnimatedLengthList.h
content/svg/content/src/DOMSVGAnimatedNumberList.cpp
content/svg/content/src/DOMSVGAnimatedNumberList.h
content/svg/content/src/DOMSVGLengthList.cpp
content/svg/content/src/DOMSVGLengthList.h
content/svg/content/src/DOMSVGNumberList.cpp
content/svg/content/src/DOMSVGNumberList.h
content/svg/content/src/DOMSVGPathSeg.h
content/svg/content/src/DOMSVGPathSegList.cpp
content/svg/content/src/DOMSVGPathSegList.h
content/svg/content/src/DOMSVGPointList.cpp
content/svg/content/src/DOMSVGPointList.h
content/svg/content/src/DOMSVGStringList.cpp
content/svg/content/src/DOMSVGStringList.h
content/svg/content/src/DOMSVGTransformList.cpp
content/svg/content/src/DOMSVGTransformList.h
content/svg/content/src/SVGAngle.cpp
content/svg/content/src/SVGAngle.h
content/svg/content/src/SVGAnimatedAngle.cpp
content/svg/content/src/SVGAnimatedAngle.h
content/svg/content/src/SVGAnimatedBoolean.cpp
content/svg/content/src/SVGAnimatedBoolean.h
content/svg/content/src/SVGAnimatedLength.cpp
content/svg/content/src/SVGAnimatedLength.h
content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp
content/svg/content/src/SVGAnimatedPreserveAspectRatio.h
content/svg/content/src/SVGAnimatedTransformList.cpp
content/svg/content/src/SVGAnimatedTransformList.h
content/svg/content/src/SVGIRect.h
content/svg/content/src/SVGMatrix.cpp
content/svg/content/src/SVGMatrix.h
content/svg/content/src/SVGPreserveAspectRatio.cpp
content/svg/content/src/SVGPreserveAspectRatio.h
content/svg/content/src/SVGTransform.cpp
content/svg/content/src/SVGTransform.h
content/svg/content/src/nsISVGPoint.h
content/xbl/src/nsBindingManager.cpp
content/xslt/src/xpath/nsXPathEvaluator.cpp
content/xslt/src/xpath/nsXPathEvaluator.h
dom/activities/src/Activity.cpp
dom/activities/src/Activity.h
dom/base/DOMCursor.cpp
dom/base/DOMCursor.h
dom/base/DOMRequest.cpp
dom/base/DOMRequest.h
dom/base/nsGlobalWindow.h
dom/base/nsJSEnvironment.cpp
dom/base/nsPerformance.cpp
dom/base/nsPerformance.h
dom/base/nsScreen.cpp
dom/base/nsScreen.h
dom/base/nsWrapperCache.h
dom/battery/BatteryManager.cpp
dom/battery/BatteryManager.h
dom/bindings/BindingUtils.h
dom/bindings/Codegen.py
dom/bindings/test/TestBindingHeader.h
dom/encoding/TextDecoder.h
dom/encoding/TextEncoder.h
dom/file/ArchiveReader.cpp
dom/file/ArchiveReader.h
dom/file/ArchiveRequest.cpp
dom/file/ArchiveRequest.h
dom/file/DOMFileRequest.cpp
dom/file/DOMFileRequest.h
dom/file/FileHandle.cpp
dom/file/FileHandle.h
dom/indexedDB/IDBEvents.h
dom/indexedDB/IDBFactory.cpp
dom/indexedDB/IDBFactory.h
dom/src/geolocation/nsGeoPosition.cpp
dom/src/geolocation/nsGeoPosition.h
dom/src/geolocation/nsGeolocation.cpp
dom/src/geolocation/nsGeolocation.h
dom/src/notification/DesktopNotification.cpp
dom/src/notification/DesktopNotification.h
dom/src/notification/Notification.cpp
dom/src/notification/Notification.h
dom/system/gonk/AudioChannelManager.cpp
dom/system/gonk/AudioChannelManager.h
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
layout/style/nsCSSStyleSheet.cpp
layout/style/nsCSSStyleSheet.h
layout/style/nsDOMCSSDeclaration.h
layout/style/nsDOMCSSRGBColor.cpp
layout/style/nsDOMCSSRGBColor.h
layout/style/nsDOMCSSRect.cpp
layout/style/nsDOMCSSRect.h
layout/style/nsDOMCSSValueList.cpp
layout/style/nsDOMCSSValueList.h
layout/style/nsROCSSPrimitiveValue.cpp
layout/style/nsROCSSPrimitiveValue.h
layout/xul/tree/nsTreeColumns.cpp
layout/xul/tree/nsTreeColumns.h
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -880,17 +880,17 @@ public:
                            const nsAString& aLocalName,
                            nsIDOMHTMLCollection** aResult);
   nsresult
     GetElementsByClassName(const nsAString& aClassNames,
                            nsIDOMHTMLCollection** aResult);
   void GetClassList(nsISupports** aClassList);
 
   virtual JSObject* WrapObject(JSContext *aCx,
-                               JSObject *aScope) MOZ_FINAL MOZ_OVERRIDE;
+                               JS::Handle<JSObject*> aScope) MOZ_FINAL MOZ_OVERRIDE;
 
   /**
    * Locate an nsIEditor rooted at this content node, if there is one.
    */
   nsIEditor* GetEditorInternal();
 
   /**
    * Helper method for NS_IMPL_BOOL_ATTR macro.
--- a/content/base/public/FragmentOrElement.h
+++ b/content/base/public/FragmentOrElement.h
@@ -49,17 +49,18 @@ public:
   {
     SetIsDOMBinding();
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(nsChildContentList)
 
   // nsWrapperCache
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   // nsIDOMNodeList interface
   NS_DECL_NSIDOMNODELIST
 
   // nsINodeList interface
   virtual int32_t IndexOf(nsIContent* aContent);
   virtual nsIContent* Item(uint32_t aIndex);
 
--- a/content/base/public/nsDOMFile.h
+++ b/content/base/public/nsDOMFile.h
@@ -432,17 +432,18 @@ public:
     SetIsDOMBinding();
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMFileList)
 
   NS_DECL_NSIDOMFILELIST
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   nsISupports* GetParentObject()
   {
     return mParent;
   }
 
   void Disconnect()
   {
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -373,17 +373,18 @@ public:
    * type, such as Text, Document, Comment ...  Use this when you can instead of
    * checking the tag.
    *
    * @param aFlags what types you want to test for (see above)
    * @return whether the content matches ALL flags passed in
    */
   virtual bool IsNodeOfType(uint32_t aFlags) const = 0;
 
-  virtual JSObject* WrapObject(JSContext *aCx, JSObject *aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
 protected:
   /**
    * WrapNode is called from WrapObject to actually wrap this node, WrapObject
    * does some additional checks and fix-up that's common to all nodes. WrapNode
    * should just call the DOM binding's Wrap function.
    */
   virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope)
--- a/content/base/src/Attr.cpp
+++ b/content/base/src/Attr.cpp
@@ -372,15 +372,15 @@ Attr::Initialize()
 
 void
 Attr::Shutdown()
 {
   sInitialized = false;
 }
 
 JSObject*
-Attr::WrapObject(JSContext* aCx, JSObject* aScope)
+Attr::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AttrBinding::Wrap(aCx, aScope, this);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/content/base/src/Attr.h
+++ b/content/base/src/Attr.h
@@ -76,17 +76,18 @@ public:
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Attr,
                                                          nsIAttribute)
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
 
   // WebIDL
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // XPCOM GetName() is OK
   // XPCOM GetValue() is OK
 
   void SetValue(const nsAString& aValue, ErrorResult& aRv);
 
   bool Specified() const;
 
--- a/content/base/src/DOMImplementation.cpp
+++ b/content/base/src/DOMImplementation.cpp
@@ -22,17 +22,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DOMImplementation, mOwner)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMImplementation)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMImplementation)
 
 JSObject*
-DOMImplementation::WrapObject(JSContext* aCx, JSObject* aScope)
+DOMImplementation::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return DOMImplementationBinding::Wrap(aCx, aScope, this);
 }
 
 bool
 DOMImplementation::HasFeature(const nsAString& aFeature,
                               const nsAString& aVersion)
 {
--- a/content/base/src/DOMImplementation.h
+++ b/content/base/src/DOMImplementation.h
@@ -48,17 +48,18 @@ public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMImplementation)
 
   nsIDocument* GetParentObject() const
   {
     return mOwner;
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // nsIDOMDOMImplementation
   NS_DECL_NSIDOMDOMIMPLEMENTATION
 
   bool HasFeature(const nsAString& aFeature, const nsAString& aVersion);
 
   already_AddRefed<DocumentType>
   CreateDocumentType(const nsAString& aQualifiedName,
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -336,17 +336,17 @@ Element::GetBindingURL(nsIDocument *aDoc
   NS_ENSURE_TRUE(sc, false);
 
   *aResult = sc->StyleDisplay()->mBinding;
 
   return true;
 }
 
 JSObject*
-Element::WrapObject(JSContext *aCx, JSObject *aScope)
+Element::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
 {
   JSObject* obj = nsINode::WrapObject(aCx, aScope);
   if (!obj) {
     return nullptr;
   }
 
   nsIDocument* doc;
   if (HasFlag(NODE_FORCE_XBL_BINDINGS)) {
--- a/content/base/src/EventSource.cpp
+++ b/content/base/src/EventSource.cpp
@@ -273,17 +273,17 @@ EventSource::Init(nsISupports* aOwner,
   // url parameter, so we don't care about the InitChannelAndRequestEventSource
   // result.
   InitChannelAndRequestEventSource();
 
   return NS_OK;
 }
 
 /* virtual */ JSObject*
-EventSource::WrapObject(JSContext* aCx, JSObject* aScope)
+EventSource::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return EventSourceBinding::Wrap(aCx, aScope, this);
 }
 
 /* static */ already_AddRefed<EventSource>
 EventSource::Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
                          const EventSourceInit& aEventSourceInitDict,
                          ErrorResult& aRv)
--- a/content/base/src/EventSource.h
+++ b/content/base/src/EventSource.h
@@ -60,18 +60,18 @@ public:
 
   NS_DECL_NSIOBSERVER
   NS_DECL_NSISTREAMLISTENER
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSICHANNELEVENTSINK
   NS_DECL_NSIINTERFACEREQUESTOR
 
   // nsWrapperCache
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // WebIDL
   nsPIDOMWindow*
   GetParentObject() const
   {
     return GetOwner();
   }
   static already_AddRefed<EventSource>
--- a/content/base/src/FragmentOrElement.cpp
+++ b/content/base/src/FragmentOrElement.cpp
@@ -376,17 +376,17 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_E
 
 NS_INTERFACE_TABLE_HEAD(nsChildContentList)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_TABLE2(nsChildContentList, nsINodeList, nsIDOMNodeList)
   NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsChildContentList)
 NS_INTERFACE_MAP_END
 
 JSObject*
-nsChildContentList::WrapObject(JSContext *cx, JSObject *scope)
+nsChildContentList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return NodeListBinding::Wrap(cx, scope, this);
 }
 
 NS_IMETHODIMP
 nsChildContentList::GetLength(uint32_t* aLength)
 {
   *aLength = mNode ? mNode->GetChildCount() : 0;
--- a/content/base/src/NodeIterator.cpp
+++ b/content/base/src/NodeIterator.cpp
@@ -282,15 +282,15 @@ void NodeIterator::ContentRemoved(nsIDoc
 {
     nsINode *container = NODE_FROM(aContainer, aDocument);
 
     mPointer.AdjustAfterRemoval(mRoot, container, aChild, aPreviousSibling);
     mWorkingPointer.AdjustAfterRemoval(mRoot, container, aChild, aPreviousSibling);
 }
 
 JSObject*
-NodeIterator::WrapObject(JSContext *cx, JSObject *scope)
+NodeIterator::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
     return NodeIteratorBinding::Wrap(cx, scope, this);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/content/base/src/NodeIterator.h
+++ b/content/base/src/NodeIterator.h
@@ -65,17 +65,17 @@ public:
         return NextOrPrevNode(&NodePointer::MoveToNext, aResult);
     }
     already_AddRefed<nsINode> PreviousNode(ErrorResult& aResult)
     {
         return NextOrPrevNode(&NodePointer::MoveToPrevious, aResult);
     }
     // The XPCOM Detach() is fine for our purposes
 
-    JSObject* WrapObject(JSContext *cx, JSObject *scope);
+    JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope);
 
 private:
     struct NodePointer {
         NodePointer() : mNode(nullptr) {}
         NodePointer(nsINode *aNode, bool aBeforeNode);
 
         typedef bool (NodePointer::*MoveToMethodType)(nsINode*);
         bool MoveToNext(nsINode *aRoot);
--- a/content/base/src/TreeWalker.cpp
+++ b/content/base/src/TreeWalker.cpp
@@ -446,15 +446,15 @@ TreeWalker::NextSiblingInternal(bool aRe
         }
         if (filtered == nsIDOMNodeFilter::FILTER_ACCEPT) {
             return nullptr;
         }
     }
 }
 
 JSObject*
-TreeWalker::WrapObject(JSContext *cx, JSObject *scope)
+TreeWalker::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
     return TreeWalkerBinding::Wrap(cx, scope, this);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/content/base/src/TreeWalker.h
+++ b/content/base/src/TreeWalker.h
@@ -59,17 +59,17 @@ public:
     already_AddRefed<nsINode> ParentNode(ErrorResult& aResult);
     already_AddRefed<nsINode> FirstChild(ErrorResult& aResult);
     already_AddRefed<nsINode> LastChild(ErrorResult& aResult);
     already_AddRefed<nsINode> PreviousSibling(ErrorResult& aResult);
     already_AddRefed<nsINode> NextSibling(ErrorResult& aResult);
     already_AddRefed<nsINode> PreviousNode(ErrorResult& aResult);
     already_AddRefed<nsINode> NextNode(ErrorResult& aResult);
 
-    JSObject* WrapObject(JSContext *cx, JSObject *scope);
+    JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope);
 
 private:
     nsCOMPtr<nsINode> mCurrentNode;
 
     /*
      * Implements FirstChild and LastChild which only vary in which direction
      * they search.
      * @param aReversed Controls whether we search forwards or backwards
--- a/content/base/src/WebSocket.cpp
+++ b/content/base/src/WebSocket.cpp
@@ -471,17 +471,17 @@ WebSocket::~WebSocket()
   // If we threw during Init we never called disconnect
   if (!mDisconnected) {
     Disconnect();
   }
   nsLayoutStatics::Release();
 }
 
 JSObject*
-WebSocket::WrapObject(JSContext* cx, JSObject* scope)
+WebSocket::WrapObject(JSContext* cx, JS::Handle<JSObject*> scope)
 {
   return WebSocketBinding::Wrap(cx, scope, this);
 }
 
 //---------------------------------------------------------------------------
 // WebIDL
 //---------------------------------------------------------------------------
 
--- a/content/base/src/WebSocket.h
+++ b/content/base/src/WebSocket.h
@@ -90,17 +90,18 @@ public:
                                    bool aUseCapture,
                                    ErrorResult& aRv) MOZ_OVERRIDE;
 
   virtual void DisconnectFromOwner();
 
   // nsWrapperCache
   nsPIDOMWindow* GetParentObject() { return GetOwner(); }
 
-  JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
 public: // static helpers:
 
   // Determine if preferences allow WebSocket
   static bool PrefEnabled();
 
 public: // WebIDL interface:
 
--- a/content/base/src/nsContentList.cpp
+++ b/content/base/src/nsContentList.cpp
@@ -130,17 +130,17 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED_1(nsS
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsSimpleContentList)
 NS_INTERFACE_MAP_END_INHERITING(nsBaseContentList)
 
 
 NS_IMPL_ADDREF_INHERITED(nsSimpleContentList, nsBaseContentList)
 NS_IMPL_RELEASE_INHERITED(nsSimpleContentList, nsBaseContentList)
 
 JSObject*
-nsSimpleContentList::WrapObject(JSContext *cx, JSObject *scope)
+nsSimpleContentList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return NodeListBinding::Wrap(cx, scope, this);
 }
 
 // nsFormContentList
 
 nsFormContentList::nsFormContentList(nsIContent *aForm,
                                      nsBaseContentList& aContentList)
@@ -263,24 +263,24 @@ NS_GetContentList(nsINode* aRootNode,
 #ifdef DEBUG
 const nsCacheableFuncStringContentList::ContentListType
   nsCacheableFuncStringNodeList::sType = nsCacheableFuncStringContentList::eNodeList;
 const nsCacheableFuncStringContentList::ContentListType
   nsCacheableFuncStringHTMLCollection::sType = nsCacheableFuncStringContentList::eHTMLCollection;
 #endif
 
 JSObject*
-nsCacheableFuncStringNodeList::WrapObject(JSContext *cx, JSObject *scope)
+nsCacheableFuncStringNodeList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return NodeListBinding::Wrap(cx, scope, this);
 }
 
 
 JSObject*
-nsCacheableFuncStringHTMLCollection::WrapObject(JSContext *cx, JSObject *scope)
+nsCacheableFuncStringHTMLCollection::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return HTMLCollectionBinding::Wrap(cx, scope, this);
 }
 
 // Hashtable for storing nsCacheableFuncStringContentList
 static PLDHashTable gFuncStringContentListHashTable;
 
 struct FuncStringContentListHashEntry : public PLDHashEntryHdr
@@ -488,17 +488,17 @@ nsContentList::~nsContentList()
 
   if (mDestroyFunc) {
     // Clean up mData
     (*mDestroyFunc)(mData);
   }
 }
 
 JSObject*
-nsContentList::WrapObject(JSContext *cx, JSObject *scope)
+nsContentList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return HTMLCollectionBinding::Wrap(cx, scope, this);
 }
 
 NS_IMPL_ISUPPORTS_INHERITED3(nsContentList, nsBaseContentList,
                              nsIHTMLCollection, nsIDOMHTMLCollection,
                              nsIMutationObserver)
 
--- a/content/base/src/nsContentList.h
+++ b/content/base/src/nsContentList.h
@@ -86,17 +86,17 @@ public:
   }
 
   void Reset() {
     mElements.Clear();
   }
 
   virtual int32_t IndexOf(nsIContent *aContent, bool aDoFlush);
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope)
+  virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
     MOZ_OVERRIDE = 0;
 
 protected:
   nsTArray< nsCOMPtr<nsIContent> > mElements;
 };
 
 
 class nsSimpleContentList : public nsBaseContentList
@@ -110,17 +110,18 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSimpleContentList,
                                            nsBaseContentList)
 
   virtual nsINode* GetParentObject()
   {
     return mRoot;
   }
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
 private:
   // This has to be a strong reference, the root might go away before the list.
   nsCOMPtr<nsINode> mRoot;
 };
 
 // This class is used only by form element code and this is a static
 // list of elements. NOTE! This list holds strong references to
@@ -241,17 +242,18 @@ public:
                 bool aDeep = true,
                 nsIAtom* aMatchAtom = nullptr,
                 int32_t aMatchNameSpaceId = kNameSpaceID_None,
                 bool aFuncMayDependOnAttr = true);
   virtual ~nsContentList();
 
   // nsWrapperCache
   using nsWrapperCache::GetWrapperPreserveColor;
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   // nsIDOMHTMLCollection
   NS_DECL_NSIDOMHTMLCOLLECTION
 
   // nsBaseContentList overrides
   virtual int32_t IndexOf(nsIContent *aContent, bool aDoFlush);
   virtual int32_t IndexOf(nsIContent* aContent);
   virtual nsINode* GetParentObject()
@@ -510,17 +512,18 @@ public:
     : nsCacheableFuncStringContentList(aRootNode, aFunc, aDestroyFunc,
                                        aDataAllocator, aString)
   {
 #ifdef DEBUG
     mType = eNodeList;
 #endif
   }
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
 #ifdef DEBUG
   static const ContentListType sType;
 #endif
 };
 
 class nsCacheableFuncStringHTMLCollection
   : public nsCacheableFuncStringContentList
@@ -534,16 +537,17 @@ public:
     : nsCacheableFuncStringContentList(aRootNode, aFunc, aDestroyFunc,
                                        aDataAllocator, aString)
   {
 #ifdef DEBUG
     mType = eHTMLCollection;
 #endif
   }
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
 #ifdef DEBUG
   static const ContentListType sType;
 #endif
 };
 
 #endif // nsContentList_h___
--- a/content/base/src/nsDOMCaretPosition.cpp
+++ b/content/base/src/nsDOMCaretPosition.cpp
@@ -48,17 +48,17 @@ nsDOMCaretPosition::GetClientRect() cons
   NS_ASSERTION(domRange, "unable to retrieve valid dom range from CaretPosition");
 
   rect = domRange->GetBoundingClientRect();
 
   return rect.forget();
 }
 
 JSObject*
-nsDOMCaretPosition::WrapObject(JSContext *aCx, JSObject *aScope)
+nsDOMCaretPosition::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
 {
   return mozilla::dom::CaretPositionBinding::Wrap(aCx, aScope, this);
 }
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(nsDOMCaretPosition,
                                         mOffsetNode, mAnonymousContentNode)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCaretPosition)
--- a/content/base/src/nsDOMCaretPosition.h
+++ b/content/base/src/nsDOMCaretPosition.h
@@ -75,17 +75,17 @@ public:
     mAnonymousContentNode = aNode;
   }
 
   nsISupports* GetParentObject() const
   {
     return GetOffsetNode();
   }
 
-  virtual JSObject* WrapObject(JSContext *aCx, JSObject *aScope)
+  virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
     MOZ_OVERRIDE MOZ_FINAL;
 
 protected:
   virtual ~nsDOMCaretPosition();
 
   uint32_t mOffset;
   nsCOMPtr<nsINode> mOffsetNode;
   nsCOMPtr<nsINode> mAnonymousContentNode;
--- a/content/base/src/nsDOMFile.cpp
+++ b/content/base/src/nsDOMFile.cpp
@@ -728,17 +728,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMFileList)
   NS_INTERFACE_MAP_ENTRY(nsIDOMFileList)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMFileList)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMFileList)
 
 JSObject*
-nsDOMFileList::WrapObject(JSContext *cx, JSObject *scope)
+nsDOMFileList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return FileListBinding::Wrap(cx, scope, this);
 }
 
 NS_IMETHODIMP
 nsDOMFileList::GetLength(uint32_t* aLength)
 {
   *aLength = Length();
--- a/content/base/src/nsDOMFileReader.cpp
+++ b/content/base/src/nsDOMFileReader.cpp
@@ -552,12 +552,12 @@ nsDOMFileReader::ConvertStream(const cha
   int32_t srcLength = aDataLen;
   rv = unicodeDecoder->Convert(aFileData, &srcLength, aResult.BeginWriting(), &destLength);
   aResult.SetLength(destLength); //Trim down to the correct size
 
   return rv;
 }
 
 /* virtual */ JSObject*
-nsDOMFileReader::WrapObject(JSContext* aCx, JSObject* aScope)
+nsDOMFileReader::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return FileReaderBinding::Wrap(aCx, aScope, this);
 }
--- a/content/base/src/nsDOMFileReader.h
+++ b/content/base/src/nsDOMFileReader.h
@@ -54,17 +54,18 @@ public:
   NS_IMETHOD DoOnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
                                nsIInputStream* aInputStream, uint64_t aOffset,
                                uint32_t aCount);
 
   nsPIDOMWindow* GetParentObject() const
   {
     return GetOwner();
   }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // WebIDL
   static already_AddRefed<nsDOMFileReader>
   Constructor(const mozilla::dom::GlobalObject& aGlobal, ErrorResult& aRv);
   void ReadAsArrayBuffer(JSContext* aCx, nsIDOMBlob* aBlob, ErrorResult& aRv)
   {
     MOZ_ASSERT(aBlob);
     ReadFileContent(aCx, aBlob, EmptyString(), FILE_AS_ARRAYBUFFER, aRv);
--- a/content/base/src/nsDOMMutationObserver.h
+++ b/content/base/src/nsDOMMutationObserver.h
@@ -39,17 +39,18 @@ public:
   }
   virtual ~nsDOMMutationRecord() {}
 
   nsISupports* GetParentObject() const
   {
     return mOwner;
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::MutationRecordBinding::Wrap(aCx, aScope, this);
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMMutationRecord)
 
   void GetType(nsString& aRetVal) const
@@ -352,17 +353,18 @@ public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMMutationObserver)
 
   static already_AddRefed<nsDOMMutationObserver>
   Constructor(const mozilla::dom::GlobalObject& aGlobal,
               mozilla::dom::MutationCallback& aCb,
               mozilla::ErrorResult& aRv);
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::MutationObserverBinding::Wrap(aCx, aScope, this);
   }
 
   nsISupports* GetParentObject() const
   {
     return mOwner;
   }
--- a/content/base/src/nsDOMParser.h
+++ b/content/base/src/nsDOMParser.h
@@ -64,17 +64,18 @@ public:
   void Init(nsIPrincipal* aPrincipal, nsIURI* aDocumentURI,
             nsIURI* aBaseURI, mozilla::ErrorResult& rv);
 
   nsISupports* GetParentObject() const
   {
     return mOwner;
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::DOMParserBinding::Wrap(aCx, aScope, this);
   }
 
 private:
   nsDOMParser(nsISupports* aOwner) : mOwner(aOwner), mAttemptedInit(false)
   {
     MOZ_ASSERT(aOwner);
--- a/content/base/src/nsDOMSerializer.h
+++ b/content/base/src/nsDOMSerializer.h
@@ -44,17 +44,18 @@ public:
   SerializeToStream(nsINode& aRoot, nsIOutputStream* aStream,
                     const nsAString& aCharset, mozilla::ErrorResult& rv);
 
   nsISupports* GetParentObject() const
   {
     return mOwner;
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::XMLSerializerBinding::Wrap(aCx, aScope, this);
   }
 
 private:
   nsDOMSerializer(nsISupports* aOwner) : mOwner(aOwner)
   {
     MOZ_ASSERT(aOwner);
--- a/content/base/src/nsDOMSettableTokenList.cpp
+++ b/content/base/src/nsDOMSettableTokenList.cpp
@@ -16,12 +16,12 @@ nsDOMSettableTokenList::SetValue(const n
   if (!mElement) {
     return;
   }
 
   rv = mElement->SetAttr(kNameSpaceID_None, mAttrAtom, aValue, true);
 }
 
 JSObject*
-nsDOMSettableTokenList::WrapObject(JSContext *cx, JSObject *scope)
+nsDOMSettableTokenList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return mozilla::dom::DOMSettableTokenListBinding::Wrap(cx, scope, this);
 }
--- a/content/base/src/nsDOMSettableTokenList.h
+++ b/content/base/src/nsDOMSettableTokenList.h
@@ -17,17 +17,18 @@ class nsIAtom;
 // because nsDOMSettableTokenList is traversed by Element.
 class nsDOMSettableTokenList MOZ_FINAL : public nsDOMTokenList
 {
 public:
 
   nsDOMSettableTokenList(mozilla::dom::Element* aElement, nsIAtom* aAttrAtom)
     : nsDOMTokenList(aElement, aAttrAtom) {}
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   // WebIDL
   void GetValue(nsAString& aResult) { Stringify(aResult); }
   void SetValue(const nsAString& aValue, mozilla::ErrorResult& rv);
 };
 
 #endif // nsDOMSettableTokenList_h___
 
--- a/content/base/src/nsDOMTokenList.cpp
+++ b/content/base/src/nsDOMTokenList.cpp
@@ -256,13 +256,13 @@ nsDOMTokenList::Stringify(nsAString& aRe
     aResult.Truncate();
     return;
   }
 
   mElement->GetAttr(kNameSpaceID_None, mAttrAtom, aResult);
 }
 
 JSObject*
-nsDOMTokenList::WrapObject(JSContext *cx, JSObject *scope)
+nsDOMTokenList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return DOMTokenListBinding::Wrap(cx, scope, this);
 }
 
--- a/content/base/src/nsDOMTokenList.h
+++ b/content/base/src/nsDOMTokenList.h
@@ -35,17 +35,18 @@ protected:
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMTokenList)
 
   nsDOMTokenList(Element* aElement, nsIAtom* aAttrAtom);
 
   void DropReference();
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   Element* GetParentObject()
   {
     return mElement;
   }
 
   uint32_t Length();
   void Item(uint32_t aIndex, nsAString& aResult)
--- a/content/base/src/nsFormData.cpp
+++ b/content/base/src/nsFormData.cpp
@@ -97,17 +97,17 @@ nsFormData::Append(const nsAString& aNam
   nsString valAsString;
   valAsString.Adopt(stringData, stringLen);
 
   Append(aName, valAsString);
   return NS_OK;
 }
 
 /* virtual */ JSObject*
-nsFormData::WrapObject(JSContext* aCx, JSObject* aScope)
+nsFormData::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return FormDataBinding::Wrap(aCx, aScope, this);
 }
 
 /* static */ already_AddRefed<nsFormData>
 nsFormData::Constructor(const GlobalObject& aGlobal,
                         const Optional<nsHTMLFormElement*>& aFormElement,
                         ErrorResult& aRv)
--- a/content/base/src/nsFormData.h
+++ b/content/base/src/nsFormData.h
@@ -35,18 +35,18 @@ public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsFormData,
                                                          nsIDOMFormData)
 
   NS_DECL_NSIDOMFORMDATA
   NS_DECL_NSIXHRSENDABLE
 
   // nsWrapperCache
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // WebIDL
   nsISupports*
   GetParentObject() const
   {
     return mOwner;
   }
   static already_AddRefed<nsFormData>
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -2372,17 +2372,17 @@ nsINode::QuerySelectorAll(const nsAStrin
   nsRefPtr<nsSimpleContentList> contentList = new nsSimpleContentList(this);
 
   aResult = FindMatchingElements<false>(this, aSelector, *contentList);
 
   return contentList.forget();
 }
 
 JSObject*
-nsINode::WrapObject(JSContext *aCx, JSObject *aScope)
+nsINode::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
 {
   MOZ_ASSERT(IsDOMBinding());
 
   // Make sure one of these is true
   // (1) our owner document has a script handling object,
   // (2) Our owner document has had a script handling object, or has been marked
   //     to have had one,
   // (3) we are running a privileged script.
--- a/content/base/src/nsRange.cpp
+++ b/content/base/src/nsRange.cpp
@@ -32,17 +32,17 @@
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/RangeBinding.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Likely.h"
 
 using namespace mozilla;
 
 JSObject*
-nsRange::WrapObject(JSContext* aCx, JSObject* aScope)
+nsRange::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return dom::RangeBinding::Wrap(aCx, aScope, this);
 }
 
 /******************************************************
  * stack based utilty class for managing monitor
  ******************************************************/
 
--- a/content/base/src/nsRange.h
+++ b/content/base/src/nsRange.h
@@ -195,17 +195,18 @@ public:
   void SetStart(nsINode& aNode, uint32_t aOffset, ErrorResult& aErr);
   void SetStartAfter(nsINode& aNode, ErrorResult& aErr);
   void SetStartBefore(nsINode& aNode, ErrorResult& aErr);
   void SurroundContents(nsINode& aNode, ErrorResult& aErr);
   already_AddRefed<nsClientRect> GetBoundingClientRect();
   already_AddRefed<nsClientRectList> GetClientRects();
 
   nsINode* GetParentObject() const { return mOwner; }
-  virtual JSObject* WrapObject(JSContext* cx, JSObject* scope) MOZ_OVERRIDE MOZ_FINAL;
+  virtual JSObject* WrapObject(JSContext* cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE MOZ_FINAL;
 
 private:
   // no copy's or assigns
   nsRange(const nsRange&);
   nsRange& operator=(const nsRange&);
 
   /**
    * Cut or delete the range's contents.
--- a/content/base/src/nsXMLHttpRequest.h
+++ b/content/base/src/nsXMLHttpRequest.h
@@ -89,17 +89,18 @@ public:
     BindToOwner(aOwner);
     SetIsDOMBinding();
   }                                         
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::)
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsXHREventTarget)
   NS_DECL_NSIXMLHTTPREQUESTUPLOAD
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE
   {
     return mozilla::dom::XMLHttpRequestUploadBinding::Wrap(cx, scope, this);
   }
   nsISupports* GetParentObject()
   {
     return GetOwner();
   }
 
@@ -126,17 +127,18 @@ class nsXMLHttpRequest : public nsXHREve
 {
   friend class nsXHRParseEndListener;
   friend class nsXMLHttpRequestXPCOMifier;
 
 public:
   nsXMLHttpRequest();
   virtual ~nsXMLHttpRequest();
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE
   {
     return mozilla::dom::XMLHttpRequestBinding::Wrap(cx, scope, this);
   }
   nsISupports* GetParentObject()
   {
     return GetOwner();
   }
 
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -526,17 +526,17 @@ CanvasRenderingContext2D::~CanvasRenderi
   }
   sNumLivingContexts--;
   if (!sNumLivingContexts) {
     NS_IF_RELEASE(sErrorTarget);
   }
 }
 
 JSObject*
-CanvasRenderingContext2D::WrapObject(JSContext *cx, JSObject *scope)
+CanvasRenderingContext2D::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return CanvasRenderingContext2DBinding::Wrap(cx, scope, this);
 }
 
 bool
 CanvasRenderingContext2D::ParseColor(const nsAString& aString,
                                      nscolor* aColor)
 {
--- a/content/canvas/src/CanvasRenderingContext2D.h
+++ b/content/canvas/src/CanvasRenderingContext2D.h
@@ -136,17 +136,18 @@ class CanvasRenderingContext2D :
 {
 typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
   HTMLImageOrCanvasOrVideoElement;
 
 public:
   CanvasRenderingContext2D();
   virtual ~CanvasRenderingContext2D();
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   HTMLCanvasElement* GetCanvas() const
   {
     // corresponds to changes to the old bindings made in bug 745025
     return mCanvasElement->GetOriginalCanvas();
   }
 
   void Save();
--- a/content/canvas/src/ImageData.cpp
+++ b/content/canvas/src/ImageData.cpp
@@ -45,15 +45,15 @@ ImageData::DropData()
 {
   if (mData) {
     mData = nullptr;
     NS_DROP_JS_OBJECTS(this, ImageData);
   }
 }
 
 JSObject*
-ImageData::WrapObject(JSContext* cx, JSObject* scope)
+ImageData::WrapObject(JSContext* cx, JS::Handle<JSObject*> scope)
 {
   return ImageDataBinding::Wrap(cx, scope, this);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/content/canvas/src/ImageData.h
+++ b/content/canvas/src/ImageData.h
@@ -55,17 +55,17 @@ public:
     return GetDataObject();
   }
   JSObject* GetDataObject() const
   {
     xpc_UnmarkGrayObject(mData);
     return mData;
   }
 
-  JSObject* WrapObject(JSContext* cx, JSObject* scope);
+  JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> scope);
 
 private:
   void HoldData();
   void DropData();
 
   ImageData() MOZ_DELETE;
 
   uint32_t mWidth, mHeight;
--- a/content/canvas/src/TextMetrics.h
+++ b/content/canvas/src/TextMetrics.h
@@ -25,17 +25,18 @@ public:
     MOZ_COUNT_DTOR(TextMetrics);
   }
 
   float Width() const
   {
     return width;
   }
 
-  JSObject* WrapObject(JSContext* aCx, JSObject* aScope, bool* aTookOwnership)
+  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope,
+                       bool* aTookOwnership)
   {
     return TextMetricsBinding::Wrap(aCx, aScope, this, aTookOwnership);
   }
 
 private:
   float width;
 };
 
--- a/content/canvas/src/WebGLActiveInfo.cpp
+++ b/content/canvas/src/WebGLActiveInfo.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WebGLContext.h"
 #include "mozilla/dom/WebGLRenderingContextBinding.h"
 
 using namespace mozilla;
 
 JSObject*
-WebGLActiveInfo::WrapObject(JSContext *cx, JSObject *scope) {
+WebGLActiveInfo::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) {
     return dom::WebGLActiveInfoBinding::Wrap(cx, scope, this);
 }
 
 NS_IMPL_ADDREF(WebGLActiveInfo)
 NS_IMPL_RELEASE(WebGLActiveInfo)
 
 NS_INTERFACE_MAP_BEGIN(WebGLActiveInfo)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
--- a/content/canvas/src/WebGLBuffer.cpp
+++ b/content/canvas/src/WebGLBuffer.cpp
@@ -51,17 +51,17 @@ WebGLBuffer::ElementArrayCacheBufferData
 
 void
 WebGLBuffer::ElementArrayCacheBufferSubData(size_t pos, const void* ptr, size_t update_size_in_bytes) {
     if (mTarget == LOCAL_GL_ELEMENT_ARRAY_BUFFER)
         mCache->BufferSubData(pos, ptr, update_size_in_bytes);
 }
 
 JSObject*
-WebGLBuffer::WrapObject(JSContext *cx, JSObject *scope) {
+WebGLBuffer::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) {
     return dom::WebGLBufferBinding::Wrap(cx, scope, this);
 }
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLBuffer)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLBuffer)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLBuffer)
 
--- a/content/canvas/src/WebGLBuffer.h
+++ b/content/canvas/src/WebGLBuffer.h
@@ -51,17 +51,18 @@ public:
     bool Validate(WebGLenum type, uint32_t max_allowed, size_t first, size_t count) {
         return mCache->Validate(type, max_allowed, first, count);
     }
 
     WebGLContext *GetParentObject() const {
         return Context();
     }
 
-    virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+    virtual JSObject* WrapObject(JSContext *cx,
+                                 JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLBuffer)
 
 protected:
 
     WebGLuint mGLName;
     bool mHasEverBeenBound;
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -202,17 +202,17 @@ WebGLContext::~WebGLContext()
 {
     DestroyResourcesAndContext();
     WebGLMemoryMultiReporterWrapper::RemoveWebGLContext(this);
     TerminateContextLossTimer();
     mContextRestorer = nullptr;
 }
 
 JSObject*
-WebGLContext::WrapObject(JSContext *cx, JSObject *scope)
+WebGLContext::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
     return dom::WebGLRenderingContextBinding::Wrap(cx, scope, this);
 }
 
 void
 WebGLContext::DestroyResourcesAndContext()
 {
     if (mMemoryPressureObserver) {
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -191,17 +191,18 @@ public:
     WebGLContext();
     virtual ~WebGLContext();
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
     NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(WebGLContext,
                                                            nsIDOMWebGLRenderingContext)
 
-    virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+    virtual JSObject* WrapObject(JSContext *cx,
+                                 JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
     NS_DECL_NSIDOMWEBGLRENDERINGCONTEXT
 
     // nsICanvasRenderingContextInternal
     NS_IMETHOD SetDimensions(int32_t width, int32_t height);
     NS_IMETHOD InitializeWithSurface(nsIDocShell *docShell, gfxASurface *surface, int32_t width, int32_t height)
         { return NS_ERROR_NOT_IMPLEMENTED; }
     NS_IMETHOD Reset()
@@ -1195,17 +1196,17 @@ public:
     WebGLenum Type() const {
         return mType;
     }
 
     void GetName(nsString& retval) const {
         retval = mName;
     }
 
-    virtual JSObject* WrapObject(JSContext *cx, JSObject *scope);
+    JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope);
 
     NS_DECL_ISUPPORTS
 
 protected:
     WebGLint mSize;
     WebGLenum mType;
     nsString mName;
 };
--- a/content/canvas/src/WebGLExtensions.h
+++ b/content/canvas/src/WebGLExtensions.h
@@ -22,22 +22,23 @@ public:
     WebGLContext *GetParentObject() const {
         return Context();
     }
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLExtensionBase)
 };
 
-#define DECL_WEBGL_EXTENSION_GOOP \
-    JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+#define DECL_WEBGL_EXTENSION_GOOP                                           \
+    virtual JSObject* WrapObject(JSContext *cx,                             \
+                                 JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
 #define IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionType) \
     JSObject* \
-    WebGLExtensionType::WrapObject(JSContext *cx, JSObject *scope) { \
+    WebGLExtensionType::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) { \
         return dom::WebGLExtensionType##Binding::Wrap(cx, scope, this); \
     }
 
 class WebGLExtensionCompressedTextureATC
     : public WebGLExtensionBase
 {
 public:
     WebGLExtensionCompressedTextureATC(WebGLContext*);
--- a/content/canvas/src/WebGLFramebuffer.cpp
+++ b/content/canvas/src/WebGLFramebuffer.cpp
@@ -6,17 +6,17 @@
 #include "WebGLContext.h"
 #include "WebGLFramebuffer.h"
 #include "mozilla/dom/WebGLRenderingContextBinding.h"
 #include "nsContentUtils.h"
 
 using namespace mozilla;
 
 JSObject*
-WebGLFramebuffer::WrapObject(JSContext *cx, JSObject *scope) {
+WebGLFramebuffer::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) {
     return dom::WebGLFramebufferBinding::Wrap(cx, scope, this);
 }
 
 WebGLFramebuffer::WebGLFramebuffer(WebGLContext *context)
     : WebGLContextBoundObject(context)
     , mHasEverBeenBound(false)
     , mColorAttachment(LOCAL_GL_COLOR_ATTACHMENT0)
     , mDepthAttachment(LOCAL_GL_DEPTH_ATTACHMENT)
--- a/content/canvas/src/WebGLFramebuffer.h
+++ b/content/canvas/src/WebGLFramebuffer.h
@@ -153,17 +153,18 @@ public:
     const WebGLRectangleObject *RectangleObject() {
         return mColorAttachment.RectangleObject();
     }
 
     WebGLContext *GetParentObject() const {
         return Context();
     }
 
-    virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+    virtual JSObject* WrapObject(JSContext *cx,
+                                 JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLFramebuffer)
 
     bool CheckAndInitializeRenderbuffers();
 
     WebGLuint mGLName;
     bool mHasEverBeenBound;
--- a/content/canvas/src/WebGLProgram.cpp
+++ b/content/canvas/src/WebGLProgram.cpp
@@ -39,17 +39,17 @@ static bool SplitLastSquareBracket(nsACS
     bracketPart.Assign(s);
     *s = 0;
     string.EndWriting();
     string.SetLength(s - string_start);
     return true;
 }
 
 JSObject*
-WebGLProgram::WrapObject(JSContext *cx, JSObject *scope) {
+WebGLProgram::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) {
     return dom::WebGLProgramBinding::Wrap(cx, scope, this);
 }
 
 WebGLProgram::WebGLProgram(WebGLContext *context)
     : WebGLContextBoundObject(context)
     , mLinkStatus(false)
     , mGeneration(0)
     , mAttribMaxNameLength(0)
--- a/content/canvas/src/WebGLProgram.h
+++ b/content/canvas/src/WebGLProgram.h
@@ -97,17 +97,18 @@ public:
      * Note: the input string |name| is the mapped identifier, not the original identifier.
      */
     WebGLUniformInfo GetUniformInfoForMappedIdentifier(const nsACString& name);
 
     WebGLContext *GetParentObject() const {
         return Context();
     }
 
-    virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+    virtual JSObject* WrapObject(JSContext *cx,
+                                 JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLProgram)
 
 protected:
 
     WebGLuint mGLName;
     bool mLinkStatus;
--- a/content/canvas/src/WebGLRenderbuffer.cpp
+++ b/content/canvas/src/WebGLRenderbuffer.cpp
@@ -6,17 +6,17 @@
 #include "WebGLContext.h"
 #include "WebGLRenderbuffer.h"
 #include "mozilla/dom/WebGLRenderingContextBinding.h"
 #include "nsContentUtils.h"
 
 using namespace mozilla;
 
 JSObject*
-WebGLRenderbuffer::WrapObject(JSContext *cx, JSObject *scope) {
+WebGLRenderbuffer::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) {
     return dom::WebGLRenderbufferBinding::Wrap(cx, scope, this);
 }
 
 WebGLRenderbuffer::WebGLRenderbuffer(WebGLContext *context)
     : WebGLContextBoundObject(context)
     , mInternalFormat(0)
     , mInternalFormatForGL(0)
     , mHasEverBeenBound(false)
--- a/content/canvas/src/WebGLRenderbuffer.h
+++ b/content/canvas/src/WebGLRenderbuffer.h
@@ -45,17 +45,18 @@ public:
     void SetInternalFormatForGL(WebGLenum aInternalFormatForGL) { mInternalFormatForGL = aInternalFormatForGL; }
 
     int64_t MemoryUsage() const;
 
     WebGLContext *GetParentObject() const {
         return Context();
     }
 
-    virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+    virtual JSObject* WrapObject(JSContext *cx,
+                                 JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLRenderbuffer)
 
 protected:
 
     WebGLuint mGLName;
     WebGLenum mInternalFormat;
--- a/content/canvas/src/WebGLShader.cpp
+++ b/content/canvas/src/WebGLShader.cpp
@@ -6,17 +6,17 @@
 #include "WebGLShader.h"
 #include "WebGLContext.h"
 #include "mozilla/dom/WebGLRenderingContextBinding.h"
 #include "nsContentUtils.h"
 
 using namespace mozilla;
 
 JSObject*
-WebGLShader::WrapObject(JSContext *cx, JSObject *scope) {
+WebGLShader::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) {
     return dom::WebGLShaderBinding::Wrap(cx, scope, this);
 }
 
 WebGLShader::WebGLShader(WebGLContext *context, WebGLenum stype)
     : WebGLContextBoundObject(context)
     , mType(stype)
     , mNeedsTranslation(true)
     , mAttribMaxNameLength(0)
--- a/content/canvas/src/WebGLShader.h
+++ b/content/canvas/src/WebGLShader.h
@@ -110,17 +110,18 @@ public:
     }
 
     const nsCString& TranslationLog() const { return mTranslationLog; }
 
     WebGLContext *GetParentObject() const {
         return Context();
     }
 
-    virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+    virtual JSObject* WrapObject(JSContext *cx,
+                                 JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLShader)
 
 protected:
 
     WebGLuint mGLName;
     WebGLenum mType;
--- a/content/canvas/src/WebGLShaderPrecisionFormat.cpp
+++ b/content/canvas/src/WebGLShaderPrecisionFormat.cpp
@@ -11,12 +11,12 @@ using namespace mozilla;
 NS_INTERFACE_MAP_BEGIN(WebGLShaderPrecisionFormat)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(WebGLShaderPrecisionFormat)
 NS_IMPL_RELEASE(WebGLShaderPrecisionFormat)
 
 JSObject*
-WebGLShaderPrecisionFormat::WrapObject(JSContext *cx, JSObject *scope)
+WebGLShaderPrecisionFormat::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
     return dom::WebGLShaderPrecisionFormatBinding::Wrap(cx, scope, this);
 }
--- a/content/canvas/src/WebGLShaderPrecisionFormat.h
+++ b/content/canvas/src/WebGLShaderPrecisionFormat.h
@@ -20,17 +20,17 @@ public:
     WebGLShaderPrecisionFormat(WebGLContext *context, WebGLint rangeMin, WebGLint rangeMax, WebGLint precision) :
         WebGLContextBoundObject(context),
         mRangeMin(rangeMin),
         mRangeMax(rangeMax),
         mPrecision(precision)
     {
     }
 
-    virtual JSObject* WrapObject(JSContext *cx, JSObject *scope);
+    JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope);
 
     NS_DECL_ISUPPORTS
 
     // WebIDL WebGLShaderPrecisionFormat API
     WebGLint RangeMin() const {
         return mRangeMin;
     }
     WebGLint RangeMax() const {
--- a/content/canvas/src/WebGLTexture.cpp
+++ b/content/canvas/src/WebGLTexture.cpp
@@ -7,17 +7,17 @@
 #include "WebGLTexture.h"
 #include "mozilla/dom/WebGLRenderingContextBinding.h"
 #include <algorithm>
 #include "nsContentUtils.h"
 
 using namespace mozilla;
 
 JSObject*
-WebGLTexture::WrapObject(JSContext *cx, JSObject *scope) {
+WebGLTexture::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) {
     return dom::WebGLTextureBinding::Wrap(cx, scope, this);
 }
 
 WebGLTexture::WebGLTexture(WebGLContext *context)
     : WebGLContextBoundObject(context)
     , mHasEverBeenBound(false)
     , mTarget(0)
     , mMinFilter(LOCAL_GL_NEAREST_MIPMAP_LINEAR)
--- a/content/canvas/src/WebGLTexture.h
+++ b/content/canvas/src/WebGLTexture.h
@@ -47,17 +47,18 @@ public:
     void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
     WebGLuint GLName() { return mGLName; }
     GLenum Target() const { return mTarget; }
 
     WebGLContext *GetParentObject() const {
         return Context();
     }
 
-    virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+    virtual JSObject* WrapObject(JSContext *cx,
+                                 JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLTexture)
 
 protected:
 
     friend class WebGLContext;
     friend class WebGLFramebuffer;
--- a/content/canvas/src/WebGLUniformLocation.cpp
+++ b/content/canvas/src/WebGLUniformLocation.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WebGLContext.h"
 #include "mozilla/dom/WebGLRenderingContextBinding.h"
 
 using namespace mozilla;
 
 JSObject*
-WebGLUniformLocation::WrapObject(JSContext *cx, JSObject *scope)
+WebGLUniformLocation::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
     return dom::WebGLUniformLocationBinding::Wrap(cx, scope, this);
 }
 
 WebGLUniformLocation::WebGLUniformLocation(WebGLContext *context, WebGLProgram *program, GLint location, const WebGLUniformInfo& info)
     : WebGLContextBoundObject(context)
     , mProgram(program)
     , mProgramGeneration(program->Generation())
--- a/content/canvas/src/WebGLUniformLocation.h
+++ b/content/canvas/src/WebGLUniformLocation.h
@@ -26,17 +26,17 @@ public:
 
     const WebGLUniformInfo &Info() const { return mInfo; }
 
     WebGLProgram *Program() const { return mProgram; }
     GLint Location() const { return mLocation; }
     uint32_t ProgramGeneration() const { return mProgramGeneration; }
     int ElementSize() const { return mElementSize; }
 
-    virtual JSObject* WrapObject(JSContext *cx, JSObject *scope);
+    JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope);
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_CYCLE_COLLECTION_CLASS(WebGLUniformLocation)
 
 protected:
     // nsRefPtr, not WebGLRefPtr, so that we don't prevent the program from being explicitly deleted.
     // we just want to avoid having a dangling pointer.
     nsRefPtr<WebGLProgram> mProgram;
--- a/content/events/src/DOMWheelEvent.h
+++ b/content/events/src/DOMWheelEvent.h
@@ -35,17 +35,18 @@ public:
                                 JSContext* aCx, JS::Value* aVal);
 
   static
   already_AddRefed<DOMWheelEvent> Constructor(const GlobalObject& aGlobal,
                                               const nsAString& aType,
                                               const WheelEventInit& aParam,
                                               mozilla::ErrorResult& aRv);
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::WheelEventBinding::Wrap(aCx, aScope, this);
   }
 
   double DeltaX()
   {
     return static_cast<widget::WheelEvent*>(mEvent)->deltaX;
   }
--- a/content/events/src/Touch.cpp
+++ b/content/events/src/Touch.cpp
@@ -140,15 +140,15 @@ Touch::Equals(nsIDOMTouch* aTouch)
   aTouch->GetRadiusY(&radiusY);
   return mRefPoint != aTouch->mRefPoint ||
          (mForce != force) ||
          (mRotationAngle != orientation) ||
          (mRadius.x != radiusX) || (mRadius.y != radiusY);
 }
 
 /* virtual */ JSObject*
-Touch::WrapObject(JSContext* aCx, JSObject* aScope)
+Touch::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return TouchBinding::Wrap(aCx, aScope, this);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/content/events/src/Touch.h
+++ b/content/events/src/Touch.h
@@ -93,17 +93,18 @@ public:
     mPointsInitialized = true;
   }
   void SetTarget(mozilla::dom::EventTarget *aTarget)
   {
     mTarget = aTarget;
   }
   bool Equals(nsIDOMTouch* aTouch);
 
-  JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
   EventTarget* GetParentObject() { return mTarget; }
 
   // WebIDL
   int32_t Identifier() const { return mIdentifier; }
   EventTarget* Target() const;
   int32_t ScreenX() const { return mScreenPoint.x; }
   int32_t ScreenY() const { return mScreenPoint.y; }
   int32_t ClientX() const { return mClientPoint.x; }
--- a/content/events/src/nsDOMAnimationEvent.h
+++ b/content/events/src/nsDOMAnimationEvent.h
@@ -20,17 +20,18 @@ public:
                       nsPresContext *aPresContext,
                       nsAnimationEvent *aEvent);
   ~nsDOMAnimationEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_TO_NSDOMEVENT
   NS_DECL_NSIDOMANIMATIONEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::AnimationEventBinding::Wrap(aCx, aScope, this);
   }
 
   // xpidl implementation
   // GetAnimationName(nsAString& aAnimationName);
 
   float ElapsedTime()
--- a/content/events/src/nsDOMBeforeUnloadEvent.h
+++ b/content/events/src/nsDOMBeforeUnloadEvent.h
@@ -16,17 +16,18 @@ class nsDOMBeforeUnloadEvent : public ns
 public:
   nsDOMBeforeUnloadEvent(mozilla::dom::EventTarget* aOwner,
                          nsPresContext* aPresContext, nsEvent* aEvent)
   : nsDOMEvent(aOwner, aPresContext, aEvent)
   {
     SetIsDOMBinding();
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::BeforeUnloadEventBinding::Wrap(aCx, aScope, this);
   }
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Forward to nsDOMEvent
   NS_FORWARD_TO_NSDOMEVENT
--- a/content/events/src/nsDOMClipboardEvent.h
+++ b/content/events/src/nsDOMClipboardEvent.h
@@ -24,17 +24,18 @@ public:
   NS_DECL_NSIDOMCLIPBOARDEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMEVENT
 
   nsresult InitFromCtor(const nsAString& aType,
                         JSContext* aCx, jsval* aVal);
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::ClipboardEventBinding::Wrap(aCx, aScope, this);
   }
 
   static already_AddRefed<nsDOMClipboardEvent>
   Constructor(const mozilla::dom::GlobalObject& aGlobal,
               const nsAString& aType,
               const mozilla::dom::ClipboardEventInit& aParam,
--- a/content/events/src/nsDOMCommandEvent.h
+++ b/content/events/src/nsDOMCommandEvent.h
@@ -21,17 +21,18 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMCOMMANDEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::CommandEventBinding::Wrap(aCx, aScope, this);
   }
 
   void InitCommandEvent(const nsAString& aType,
                         bool aCanBubble,
                         bool aCancelable,
                         const nsAString& aCommand,
--- a/content/events/src/nsDOMCompositionEvent.h
+++ b/content/events/src/nsDOMCompositionEvent.h
@@ -19,17 +19,18 @@ public:
                         nsPresContext* aPresContext,
                         nsCompositionEvent* aEvent);
   virtual ~nsDOMCompositionEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_TO_NSDOMUIEVENT
   NS_DECL_NSIDOMCOMPOSITIONEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::CompositionEventBinding::Wrap(aCx, aScope, this);
   }
 
   void
   InitCompositionEvent(const nsAString& aType,
                        bool aCanBubble,
                        bool aCancelable,
--- a/content/events/src/nsDOMDeviceMotionEvent.h
+++ b/content/events/src/nsDOMDeviceMotionEvent.h
@@ -57,17 +57,18 @@ public:
   // Forward to nsDOMEvent
   NS_FORWARD_TO_NSDOMEVENT
 
   // nsIDOMDeviceMotionEvent Interface
   NS_DECL_NSIDOMDEVICEMOTIONEVENT
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::DeviceMotionEventBinding::Wrap(aCx, aScope, this);
   }
 
   nsIDOMDeviceAcceleration* GetAcceleration()
   {
     return mAcceleration;
   }
--- a/content/events/src/nsDOMDragEvent.h
+++ b/content/events/src/nsDOMDragEvent.h
@@ -21,17 +21,18 @@ public:
   virtual ~nsDOMDragEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMDRAGEVENT
   
   NS_FORWARD_TO_NSDOMMOUSEEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::DragEventBinding::Wrap(aCx, aScope, this);
   }
 
   nsIDOMDataTransfer* GetDataTransfer();
 
   void InitDragEvent(const nsAString& aType,
                      bool aCanBubble, bool aCancelable,
--- a/content/events/src/nsDOMEvent.h
+++ b/content/events/src/nsDOMEvent.h
@@ -79,17 +79,18 @@ public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMEvent, nsIDOMEvent)
 
   nsISupports* GetParentObject()
   {
     return mOwner;
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::EventBinding::Wrap(aCx, aScope, this);
   }
 
   // nsIDOMEvent Interface
   NS_DECL_NSIDOMEVENT
 
   // nsIJSNativeInitializer
--- a/content/events/src/nsDOMGamepad.cpp
+++ b/content/events/src/nsDOMGamepad.cpp
@@ -146,12 +146,12 @@ nsDOMGamepad::Clone(nsISupports* aParent
 {
   nsRefPtr<nsDOMGamepad> out =
     new nsDOMGamepad(aParent, mID, mIndex, mButtons.Length(), mAxes.Length());
   out->SyncState(this);
   return out.forget();
 }
 
 /* virtual */ JSObject*
-nsDOMGamepad::WrapObject(JSContext* aCx, JSObject* aScope)
+nsDOMGamepad::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return GamepadBinding::Wrap(aCx, aScope, this);
 }
--- a/content/events/src/nsDOMGamepad.h
+++ b/content/events/src/nsDOMGamepad.h
@@ -36,18 +36,18 @@ public:
   // parented to aParent.
   already_AddRefed<nsDOMGamepad> Clone(nsISupports* aParent);
 
   nsISupports* GetParentObject() const
   {
     return mParent;
   }
 
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   void GetId(nsAString& aID) const
   {
     aID = mID;
   }
 
   bool Connected() const
   {
--- a/content/events/src/nsDOMKeyboardEvent.h
+++ b/content/events/src/nsDOMKeyboardEvent.h
@@ -21,17 +21,18 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMKeyEvent Interface
   NS_DECL_NSIDOMKEYEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMUIEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::KeyEventBinding::Wrap(aCx, aScope, this);
   }
 
   bool AltKey()
   {
     return static_cast<nsInputEvent*>(mEvent)->IsAlt();
   }
--- a/content/events/src/nsDOMMessageEvent.h
+++ b/content/events/src/nsDOMMessageEvent.h
@@ -31,17 +31,18 @@ public:
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsDOMMessageEvent,
                                                          nsDOMEvent)
 
   NS_DECL_NSIDOMMESSAGEEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::MessageEventBinding::Wrap(aCx, aScope, this);
   }
 
   JS::Value GetData(JSContext* aCx, mozilla::ErrorResult& aRv)
   {
     JS::Value data;
     aRv = GetData(aCx, &data);
--- a/content/events/src/nsDOMMouseEvent.h
+++ b/content/events/src/nsDOMMouseEvent.h
@@ -23,17 +23,18 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMMouseEvent Interface
   NS_DECL_NSIDOMMOUSEEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMUIEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::MouseEventBinding::Wrap(aCx, aScope, this);
   }
 
   virtual nsresult InitFromCtor(const nsAString& aType,
                                 JSContext* aCx, JS::Value* aVal);
 
   // Web IDL binding methods
--- a/content/events/src/nsDOMMouseScrollEvent.h
+++ b/content/events/src/nsDOMMouseScrollEvent.h
@@ -21,17 +21,18 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMMouseScrollEvent Interface
   NS_DECL_NSIDOMMOUSESCROLLEVENT
   
   // Forward to base class
   NS_FORWARD_TO_NSDOMMOUSEEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::MouseScrollEventBinding::Wrap(aCx, aScope, this);
   }
 
   int32_t Axis();
 
   void InitMouseScrollEvent(const nsAString& aType, bool aCanBubble,
                             bool aCancelable, nsIDOMWindow* aView,
--- a/content/events/src/nsDOMMutationEvent.h
+++ b/content/events/src/nsDOMMutationEvent.h
@@ -23,17 +23,18 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMMUTATIONEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::MutationEventBinding::Wrap(aCx, aScope, this);
   }
 
   // xpidl implementation
   // GetPrevValue(nsAString& aPrevValue);
   // GetNewValue(nsAString& aNewValue);
   // GetAttrName(nsAString& aAttrName);
--- a/content/events/src/nsDOMNotifyPaintEvent.h
+++ b/content/events/src/nsDOMNotifyPaintEvent.h
@@ -33,17 +33,18 @@ public:
   NS_FORWARD_TO_NSDOMEVENT_NO_SERIALIZATION_NO_DUPLICATION
   NS_IMETHOD DuplicatePrivateData()
   {
     return nsDOMEvent::DuplicatePrivateData();
   }
   NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType);
   NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter);
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::NotifyPaintEventBinding::Wrap(aCx, aScope, this);
   }
 
   already_AddRefed<nsClientRectList> ClientRects();
 
   already_AddRefed<nsClientRect> BoundingClientRect();
 
--- a/content/events/src/nsDOMScrollAreaEvent.h
+++ b/content/events/src/nsDOMScrollAreaEvent.h
@@ -31,17 +31,18 @@ public:
   NS_FORWARD_TO_NSDOMEVENT_NO_SERIALIZATION_NO_DUPLICATION
   NS_IMETHOD DuplicatePrivateData()
   {
     return nsDOMEvent::DuplicatePrivateData();
   }
   NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType);
   NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter);
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::ScrollAreaEventBinding::Wrap(aCx, aScope, this);
   }
 
   float X() const
   {
     return mClientArea.Left();
   }
--- a/content/events/src/nsDOMSimpleGestureEvent.h
+++ b/content/events/src/nsDOMSimpleGestureEvent.h
@@ -21,17 +21,18 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMSIMPLEGESTUREEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMMOUSEEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::SimpleGestureEventBinding::Wrap(aCx, aScope, this);
   }
 
   uint32_t AllowedDirections()
   {
     return static_cast<nsSimpleGestureEvent*>(mEvent)->allowedDirections;
   }
--- a/content/events/src/nsDOMTouchEvent.h
+++ b/content/events/src/nsDOMTouchEvent.h
@@ -49,17 +49,18 @@ public:
   virtual ~nsDOMTouchEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
   NS_DECL_NSIDOMTOUCHEVENT
 
   NS_FORWARD_TO_NSDOMUIEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::TouchEventBinding::Wrap(aCx, aScope, this);
   }
 
   already_AddRefed<nsIDOMTouchList> GetTouches()
   {
     nsCOMPtr<nsIDOMTouchList> t;
     GetTouches(getter_AddRefs(t));
--- a/content/events/src/nsDOMTransitionEvent.h
+++ b/content/events/src/nsDOMTransitionEvent.h
@@ -20,17 +20,18 @@ public:
                        nsPresContext *aPresContext,
                        nsTransitionEvent *aEvent);
   ~nsDOMTransitionEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_TO_NSDOMEVENT
   NS_DECL_NSIDOMTRANSITIONEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::TransitionEventBinding::Wrap(aCx, aScope, this);
   }
 
   // xpidl implementation
   // GetPropertyName(nsAString& aPropertyName)
 
   float ElapsedTime()
--- a/content/events/src/nsDOMUIEvent.h
+++ b/content/events/src/nsDOMUIEvent.h
@@ -87,17 +87,18 @@ public:
                       nsPresContext::AppUnitsToIntCSSPixels(pt.y));
   }
 
   static already_AddRefed<nsDOMUIEvent> Constructor(const mozilla::dom::GlobalObject& aGlobal,
                                                     const nsAString& aType,
                                                     const mozilla::dom::UIEventInit& aParam,
                                                     mozilla::ErrorResult& aRv);
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::UIEventBinding::Wrap(aCx, aScope, this);
   }
 
   already_AddRefed<nsIDOMWindow> GetView()
   {
     nsCOMPtr<nsIDOMWindow> view = mView;
     return view.forget();
--- a/content/events/src/nsDOMXULCommandEvent.h
+++ b/content/events/src/nsDOMXULCommandEvent.h
@@ -22,17 +22,18 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
   NS_DECL_NSIDOMXULCOMMANDEVENT
 
   // Forward our inherited virtual methods to the base class
   NS_FORWARD_TO_NSDOMUIEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::XULCommandEventBinding::Wrap(aCx, aScope, this);
   }
 
   bool AltKey()
   {
     return Event()->IsAlt();
   }
--- a/content/events/src/nsPaintRequest.cpp
+++ b/content/events/src/nsPaintRequest.cpp
@@ -20,17 +20,17 @@ NS_INTERFACE_TABLE_HEAD(nsPaintRequest)
   NS_INTERFACE_TABLE1(nsPaintRequest, nsIDOMPaintRequest)
   NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsPaintRequest)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPaintRequest)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPaintRequest)
 
 /* virtual */ JSObject*
-nsPaintRequest::WrapObject(JSContext* aCx, JSObject* aScope)
+nsPaintRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return PaintRequestBinding::Wrap(aCx, aScope, this);
 }
 
 already_AddRefed<nsClientRect>
 nsPaintRequest::ClientRect()
 {
   nsRefPtr<nsClientRect> clientRect = new nsClientRect(this);
@@ -60,17 +60,17 @@ NS_INTERFACE_TABLE_HEAD(nsPaintRequestLi
   NS_INTERFACE_TABLE1(nsPaintRequestList, nsIDOMPaintRequestList)
   NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsPaintRequestList)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPaintRequestList)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPaintRequestList)
 
 JSObject*
-nsPaintRequestList::WrapObject(JSContext *cx, JSObject *scope)
+nsPaintRequestList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return mozilla::dom::PaintRequestListBinding::Wrap(cx, scope, this);
 }
 
 NS_IMETHODIMP    
 nsPaintRequestList::GetLength(uint32_t* aLength)
 {
   *aLength = Length();
--- a/content/events/src/nsPaintRequest.h
+++ b/content/events/src/nsPaintRequest.h
@@ -24,17 +24,18 @@ public:
     mRequest.mFlags = 0;
     SetIsDOMBinding();
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPaintRequest)
   NS_DECL_NSIDOMPAINTREQUEST
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   nsIDOMEvent* GetParentObject() const
   {
     return mParent;
   }
 
   already_AddRefed<nsClientRect> ClientRect();
   void GetReason(nsAString& aResult) const
@@ -60,17 +61,18 @@ public:
   {
     SetIsDOMBinding();
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPaintRequestList)
   NS_DECL_NSIDOMPAINTREQUESTLIST
   
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
   nsISupports* GetParentObject()
   {
     return mParent;
   }
 
   void Append(nsPaintRequest* aElement)
   {
     mArray.AppendElement(aElement);
--- a/content/html/content/public/nsIHTMLCollection.h
+++ b/content/html/content/public/nsIHTMLCollection.h
@@ -74,14 +74,14 @@ public:
   virtual void GetSupportedNames(nsTArray<nsString>& aNames) = 0;
 
   JSObject* GetWrapperPreserveColor()
   {
     nsWrapperCache* cache;
     CallQueryInterface(this, &cache);
     return cache->GetWrapperPreserveColor();
   }
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) = 0;
+  virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLCollection, NS_IHTMLCOLLECTION_IID)
 
 #endif /* nsIHTMLCollection_h___ */
--- a/content/html/content/src/HTMLOptionsCollection.cpp
+++ b/content/html/content/src/HTMLOptionsCollection.cpp
@@ -109,17 +109,17 @@ NS_INTERFACE_TABLE_HEAD(HTMLOptionsColle
 NS_INTERFACE_MAP_END
 
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(HTMLOptionsCollection)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(HTMLOptionsCollection)
 
 
 JSObject*
-HTMLOptionsCollection::WrapObject(JSContext* aCx, JSObject* aScope)
+HTMLOptionsCollection::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return HTMLOptionsCollectionBinding::Wrap(aCx, aScope, this);
 }
 
 NS_IMETHODIMP
 HTMLOptionsCollection::GetLength(uint32_t* aLength)
 {
   *aLength = mElements.Length();
--- a/content/html/content/src/HTMLOptionsCollection.h
+++ b/content/html/content/src/HTMLOptionsCollection.h
@@ -36,17 +36,18 @@ class HTMLOptionsCollection : public nsI
 public:
   HTMLOptionsCollection(HTMLSelectElement* aSelect);
   virtual ~HTMLOptionsCollection();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   // nsWrapperCache
   using nsWrapperCache::GetWrapperPreserveColor;
-  virtual JSObject* WrapObject(JSContext* cx, JSObject* scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   // nsIDOMHTMLOptionsCollection interface
   NS_DECL_NSIDOMHTMLOPTIONSCOLLECTION
 
   // nsIDOMHTMLCollection interface, all its methods are defined in
   // nsIDOMHTMLOptionsCollection
 
   virtual Element* GetElementAt(uint32_t aIndex);
--- a/content/html/content/src/HTMLPropertiesCollection.cpp
+++ b/content/html/content/src/HTMLPropertiesCollection.cpp
@@ -90,17 +90,17 @@ HTMLPropertiesCollection::SetDocument(ns
   if (mDoc) {
     mDoc->AddMutationObserver(this);
   }
   mNamedItemEntries.EnumerateRead(SetPropertyListDocument, aDocument);
   mIsDirty = true;
 }
 
 JSObject*
-HTMLPropertiesCollection::WrapObject(JSContext* cx, JSObject* scope)
+HTMLPropertiesCollection::WrapObject(JSContext* cx, JS::Handle<JSObject*> scope)
 {
   return HTMLPropertiesCollectionBinding::Wrap(cx, scope, this);
 }
 
 NS_IMETHODIMP
 HTMLPropertiesCollection::GetLength(uint32_t* aLength)
 {
   EnsureFresh();
@@ -398,17 +398,17 @@ PropertyNodeList::IndexOf(nsIContent* aC
 
 nsINode*
 PropertyNodeList::GetParentObject()
 {
   return mParent;
 }
 
 JSObject*
-PropertyNodeList::WrapObject(JSContext *cx, JSObject *scope)
+PropertyNodeList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return PropertyNodeListBinding::Wrap(cx, scope, this);
 }
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(PropertyNodeList)
   // SetDocument(nullptr) ensures that we remove ourselves as a mutation observer
   tmp->SetDocument(nullptr);
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent)
--- a/content/html/content/src/HTMLPropertiesCollection.h
+++ b/content/html/content/src/HTMLPropertiesCollection.h
@@ -51,17 +51,18 @@ class HTMLPropertiesCollection : public 
 {
   friend class PropertyNodeList;
   friend class PropertyStringList;
 public:
   HTMLPropertiesCollection(nsGenericHTMLElement* aRoot);
   virtual ~HTMLPropertiesCollection();
 
   using nsWrapperCache::GetWrapperPreserveColor;
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   virtual Element* GetElementAt(uint32_t aIndex);
 
   void SetDocument(nsIDocument* aDocument);
   nsINode* GetParentObject();
   virtual JSObject* NamedItem(JSContext* cx, const nsAString& name,
                               mozilla::ErrorResult& error);
   PropertyNodeList* NamedItem(const nsAString& aName);
@@ -127,17 +128,18 @@ protected:
 class PropertyNodeList : public nsINodeList,
                          public nsStubMutationObserver
 {
 public:
   PropertyNodeList(HTMLPropertiesCollection* aCollection,
                    nsIContent* aRoot, const nsAString& aName);
   virtual ~PropertyNodeList();
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   void SetDocument(nsIDocument* aDocument);
 
   void GetValues(JSContext* aCx, nsTArray<JS::Value >& aResult,
                  ErrorResult& aError);
 
   virtual nsIContent* Item(uint32_t aIndex);
 
--- a/content/html/content/src/HTMLTableElement.cpp
+++ b/content/html/content/src/HTMLTableElement.cpp
@@ -46,17 +46,18 @@ public:
                               ErrorResult& error);
   virtual void GetSupportedNames(nsTArray<nsString>& aNames);
 
   NS_IMETHOD    ParentDestroyed();
 
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TableRowsCollection)
 
   // nsWrapperCache
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE
   {
     return mozilla::dom::HTMLCollectionBinding::Wrap(cx, scope, this);
   }
 
 protected:
   // Those rows that are not in table sections
   HTMLTableElement* mParent;
   nsRefPtr<nsContentList> mOrphanRows;  
--- a/content/html/content/src/MediaError.cpp
+++ b/content/html/content/src/MediaError.cpp
@@ -32,15 +32,15 @@ NS_IMETHODIMP MediaError::GetCode(uint16
 {
   if (aCode)
     *aCode = Code();
 
   return NS_OK;
 }
 
 JSObject*
-MediaError::WrapObject(JSContext* aCx, JSObject* aScope)
+MediaError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return MediaErrorBinding::Wrap(aCx, aScope, this);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/content/html/content/src/MediaError.h
+++ b/content/html/content/src/MediaError.h
@@ -29,17 +29,18 @@ public:
   // nsIDOMMediaError
   NS_DECL_NSIDOMMEDIAERROR
 
   HTMLMediaElement* GetParentObject() const
   {
     return mParent;
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   uint16_t Code() const
   {
     return mCode;
   }
 
 private:
   nsRefPtr<HTMLMediaElement> mParent;
--- a/content/html/content/src/TimeRanges.cpp
+++ b/content/html/content/src/TimeRanges.cpp
@@ -116,15 +116,15 @@ TimeRanges::Normalize()
 
     normalized.AppendElement(current);
 
     mRanges = normalized;
   }
 }
 
 JSObject*
-TimeRanges::WrapObject(JSContext* aCx, JSObject* aScope)
+TimeRanges::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return TimeRangesBinding::Wrap(aCx, aScope, this);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/content/html/content/src/TimeRanges.h
+++ b/content/html/content/src/TimeRanges.h
@@ -31,17 +31,17 @@ public:
   void Add(double aStart, double aEnd);
 
   // Returns the end time of the last range, or -1 if no ranges added.
   double GetFinalEndTime();
 
   // See http://www.whatwg.org/html/#normalized-timeranges-object
   void Normalize();
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope);
 
   uint32_t Length() const
   {
     return mRanges.Length();
   }
 
   virtual double Start(uint32_t aIndex, ErrorResult& aRv);
 
--- a/content/html/content/src/UndoManager.h
+++ b/content/html/content/src/UndoManager.h
@@ -49,17 +49,18 @@ public:
   static bool PrefEnabled();
   void Disconnect();
 
   nsISupports* GetParentObject() const
   {
     return mHostNode;
   }
 
-  JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext* aCx,
+			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::UndoManagerBinding::Wrap(aCx, aScope, this);
   }
 
   nsITransactionManager* GetTransactionManager();
 
 protected:
   virtual ~UndoManager();
--- a/content/html/content/src/ValidityState.cpp
+++ b/content/html/content/src/ValidityState.cpp
@@ -87,16 +87,16 @@ ValidityState::GetCustomError(bool* aCus
 NS_IMETHODIMP
 ValidityState::GetValid(bool* aValid)
 {
   *aValid = Valid();
   return NS_OK;
 }
 
 JSObject*
-ValidityState::WrapObject(JSContext* aCx, JSObject* aScope)
+ValidityState::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return ValidityStateBinding::Wrap(aCx, aScope, this);
 }
 
 } // namespace dom
 } // namespace mozilla
 
--- a/content/html/content/src/ValidityState.h
+++ b/content/html/content/src/ValidityState.h
@@ -25,17 +25,18 @@ public:
   NS_DECL_NSIDOMVALIDITYSTATE
 
   friend class ::nsIConstraintValidation;
 
   nsIConstraintValidation* GetParentObject() const {
     return mConstraintValidation;
   }
 
-  virtual JSObject* WrapObject(JSContext *aCx, JSObject *aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // Web IDL methods
   bool ValueMissing() const
   {
     return GetValidityState(nsIConstraintValidation::VALIDITY_STATE_VALUE_MISSING);
   }
   bool TypeMismatch() const
   {
--- a/content/html/content/src/nsClientRect.cpp
+++ b/content/html/content/src/nsClientRect.cpp
@@ -34,17 +34,17 @@ NS_INTERFACE_MAP_END
 FORWARD_GETTER(Left)
 FORWARD_GETTER(Top)
 FORWARD_GETTER(Right)
 FORWARD_GETTER(Bottom)
 FORWARD_GETTER(Width)
 FORWARD_GETTER(Height)
 
 JSObject*
-nsClientRect::WrapObject(JSContext* aCx, JSObject* aScope)
+nsClientRect::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   MOZ_ASSERT(mParent);
   return ClientRectBinding::Wrap(aCx, aScope, this);
 }
 
 // -----------------------------------------------------------------------------
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(nsClientRectList, mParent, mArray)
@@ -69,17 +69,17 @@ nsClientRectList::GetLength(uint32_t* aL
 NS_IMETHODIMP    
 nsClientRectList::Item(uint32_t aIndex, nsIDOMClientRect** aReturn)
 {
   NS_IF_ADDREF(*aReturn = Item(aIndex));
   return NS_OK;
 }
 
 JSObject*
-nsClientRectList::WrapObject(JSContext *cx, JSObject *scope)
+nsClientRectList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return mozilla::dom::ClientRectListBinding::Wrap(cx, scope, this);
 }
 
 static double
 RoundFloat(double aValue)
 {
   return floor(aValue + 0.5);
--- a/content/html/content/src/nsClientRect.h
+++ b/content/html/content/src/nsClientRect.h
@@ -39,18 +39,18 @@ public:
   NS_DECL_NSIDOMCLIENTRECT
 
 
   nsISupports* GetParentObject() const
   {
     MOZ_ASSERT(mParent);
     return mParent;
   }
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
 
   float Left() const
   {
     return mX;
   }
 
   float Top() const
@@ -92,17 +92,18 @@ public:
     SetIsDOMBinding();
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsClientRectList)
 
   NS_DECL_NSIDOMCLIENTRECTLIST
   
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   nsISupports* GetParentObject()
   {
     return mParent;
   }
 
   void Append(nsClientRect* aElement) { mArray.AppendElement(aElement); }
 
--- a/content/html/content/src/nsDOMStringMap.cpp
+++ b/content/html/content/src/nsDOMStringMap.cpp
@@ -53,17 +53,17 @@ nsDOMStringMap::~nsDOMStringMap()
   if (mElement) {
     // Call back to element to null out weak reference to this object.
     mElement->ClearDataset();
   }
 }
 
 /* virtual */
 JSObject*
-nsDOMStringMap::WrapObject(JSContext *cx, JSObject *scope)
+nsDOMStringMap::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return DOMStringMapBinding::Wrap(cx, scope, this);
 }
 
 void
 nsDOMStringMap::NamedGetter(const nsAString& aProp, bool& found,
                             nsString& aResult) const
 {
--- a/content/html/content/src/nsDOMStringMap.h
+++ b/content/html/content/src/nsDOMStringMap.h
@@ -28,17 +28,18 @@ public:
   nsINode* GetParentObject()
   {
     return mElement;
   }
 
   nsDOMStringMap(nsGenericHTMLElement* aElement);
 
   // WebIDL API
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
   void NamedGetter(const nsAString& aProp, bool& found, nsString& aResult) const;
   void NamedSetter(const nsAString& aProp, const nsAString& aValue,
                    mozilla::ErrorResult& rv);
   void NamedDeleter(const nsAString& aProp, bool &found);
   void GetSupportedNames(nsTArray<nsString>& aNames);
 
 private:
   virtual ~nsDOMStringMap();
--- a/content/html/content/src/nsHTMLFormElement.cpp
+++ b/content/html/content/src/nsHTMLFormElement.cpp
@@ -118,17 +118,18 @@ public:
    * elements.
    *
    * @param aControls The list of sorted controls[out].
    * @return NS_OK or NS_ERROR_OUT_OF_MEMORY.
    */
   nsresult GetSortedControls(nsTArray<nsGenericHTMLFormElement*>& aControls) const;
 
   // nsWrapperCache
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope)
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE
   {
     return HTMLCollectionBinding::Wrap(cx, scope, this);
   }
 
   nsHTMLFormElement* mForm;  // WEAK - the form owns me
 
   nsTArray<nsGenericHTMLFormElement*> mElements;  // Holds WEAK references - bug 36639
 
--- a/content/media/AudioStreamTrack.cpp
+++ b/content/media/AudioStreamTrack.cpp
@@ -6,15 +6,15 @@
 #include "AudioStreamTrack.h"
 
 #include "mozilla/dom/AudioStreamTrackBinding.h"
 
 namespace mozilla {
 namespace dom {
 
 JSObject*
-AudioStreamTrack::WrapObject(JSContext* aCx, JSObject* aScope)
+AudioStreamTrack::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AudioStreamTrackBinding::Wrap(aCx, aScope, this);
 }
 
 }
 }
--- a/content/media/AudioStreamTrack.h
+++ b/content/media/AudioStreamTrack.h
@@ -11,17 +11,18 @@
 namespace mozilla {
 namespace dom {
 
 class AudioStreamTrack : public MediaStreamTrack {
 public:
   AudioStreamTrack(DOMMediaStream* aStream, TrackID aTrackID)
     : MediaStreamTrack(aStream, aTrackID) {}
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual AudioStreamTrack* AsAudioStreamTrack() { return this; }
 
   // WebIDL
   virtual void GetKind(nsAString& aKind) { aKind.AssignLiteral("audio"); }
 };
 
 }
--- a/content/media/DOMMediaStream.cpp
+++ b/content/media/DOMMediaStream.cpp
@@ -113,17 +113,17 @@ DOMMediaStream::~DOMMediaStream()
     mListener->Forget();
   }
   if (mStream) {
     mStream->Destroy();
   }
 }
 
 JSObject*
-DOMMediaStream::WrapObject(JSContext* aCx, JSObject* aScope)
+DOMMediaStream::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return dom::MediaStreamBinding::Wrap(aCx, aScope, this);
 }
 
 double
 DOMMediaStream::CurrentTime()
 {
   return mStream ? MediaTimeToSeconds(mStream->GetCurrentTime()) : 0.0;
@@ -245,17 +245,17 @@ DOMLocalMediaStream::~DOMLocalMediaStrea
 {
   if (mStream) {
     // Make sure Listeners of this stream know it's going away
     Stop();
   }
 }
 
 JSObject*
-DOMLocalMediaStream::WrapObject(JSContext* aCx, JSObject* aScope)
+DOMLocalMediaStream::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return dom::LocalMediaStreamBinding::Wrap(aCx, aScope, this);
 }
 
 void
 DOMLocalMediaStream::Stop()
 {
   if (mStream && mStream->AsSourceStream()) {
--- a/content/media/DOMMediaStream.h
+++ b/content/media/DOMMediaStream.h
@@ -54,17 +54,18 @@ public:
 
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMMediaStream)
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   nsIDOMWindow* GetParentObject() const
   {
     return mWindow;
   }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // WebIDL
   double CurrentTime();
   void GetAudioTracks(nsTArray<nsRefPtr<AudioStreamTrack> >& aTracks);
   void GetVideoTracks(nsTArray<nsRefPtr<VideoStreamTrack> >& aTracks);
 
   MediaStream* GetStream() { return mStream; }
   bool IsFinished();
@@ -137,17 +138,18 @@ class DOMLocalMediaStream : public DOMMe
                             public nsIDOMLocalMediaStream
 {
 public:
   DOMLocalMediaStream() {}
   virtual ~DOMLocalMediaStream();
 
   NS_DECL_ISUPPORTS_INHERITED
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual void Stop();
 
   /**
    * Create an nsDOMLocalMediaStream whose underlying stream is a SourceMediaStream.
    */
   static already_AddRefed<DOMLocalMediaStream>
   CreateSourceStream(nsIDOMWindow* aWindow, uint32_t aHintContents);
--- a/content/media/MediaStreamTrack.h
+++ b/content/media/MediaStreamTrack.h
@@ -30,17 +30,18 @@ public:
    */
   MediaStreamTrack(DOMMediaStream* aStream, TrackID aTrackID);
   virtual ~MediaStreamTrack();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaStreamTrack, nsDOMEventTargetHelper)
 
   DOMMediaStream* GetParentObject() const { return mStream; }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) = 0;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE = 0;
 
   DOMMediaStream* GetStream() const { return mStream; }
   TrackID GetTrackID() const { return mTrackID; }
   virtual AudioStreamTrack* AsAudioStreamTrack() { return nullptr; }
   virtual VideoStreamTrack* AsVideoStreamTrack() { return nullptr; }
 
   // WebIDL
   virtual void GetKind(nsAString& aKind) = 0;
--- a/content/media/VideoStreamTrack.cpp
+++ b/content/media/VideoStreamTrack.cpp
@@ -6,15 +6,15 @@
 #include "VideoStreamTrack.h"
 
 #include "mozilla/dom/VideoStreamTrackBinding.h"
 
 namespace mozilla {
 namespace dom {
 
 JSObject*
-VideoStreamTrack::WrapObject(JSContext* aCx, JSObject* aScope)
+VideoStreamTrack::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return VideoStreamTrackBinding::Wrap(aCx, aScope, this);
 }
 
 }
 }
--- a/content/media/VideoStreamTrack.h
+++ b/content/media/VideoStreamTrack.h
@@ -11,17 +11,18 @@
 namespace mozilla {
 namespace dom {
 
 class VideoStreamTrack : public MediaStreamTrack {
 public:
   VideoStreamTrack(DOMMediaStream* aStream, TrackID aTrackID)
     : MediaStreamTrack(aStream, aTrackID) {}
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual VideoStreamTrack* AsVideoStreamTrack() { return this; }
 
   // WebIDL
   virtual void GetKind(nsAString& aKind) { aKind.AssignLiteral("video"); }
 };
 
 }
--- a/content/media/webaudio/AnalyserNode.cpp
+++ b/content/media/webaudio/AnalyserNode.cpp
@@ -83,17 +83,17 @@ AnalyserNode::AnalyserNode(AudioContext*
   , mWriteIndex(0)
 {
   mStream = aContext->Graph()->CreateAudioNodeStream(new AnalyserNodeEngine(this),
                                                      MediaStreamGraph::INTERNAL_STREAM);
   AllocateBuffer();
 }
 
 JSObject*
-AnalyserNode::WrapObject(JSContext* aCx, JSObject* aScope)
+AnalyserNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AnalyserNodeBinding::Wrap(aCx, aScope, this);
 }
 
 void
 AnalyserNode::SetFftSize(uint32_t aValue, ErrorResult& aRv)
 {
   // Disallow values that are not a power of 2 and outside the [32,2048] range
--- a/content/media/webaudio/AnalyserNode.h
+++ b/content/media/webaudio/AnalyserNode.h
@@ -16,17 +16,18 @@ class AudioContext;
 
 class AnalyserNode : public AudioNode
 {
 public:
   explicit AnalyserNode(AudioContext* aContext);
 
   NS_DECL_ISUPPORTS_INHERITED
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual bool SupportsMediaStreams() const MOZ_OVERRIDE
   {
     return true;
   }
 
   void GetFloatFrequencyData(Float32Array& aArray);
   void GetByteFrequencyData(Uint8Array& aArray);
--- a/content/media/webaudio/AudioBuffer.cpp
+++ b/content/media/webaudio/AudioBuffer.cpp
@@ -79,17 +79,17 @@ AudioBuffer::InitializeBuffers(uint32_t 
     }
     mJSChannels.AppendElement(array);
   }
 
   return true;
 }
 
 JSObject*
-AudioBuffer::WrapObject(JSContext* aCx, JSObject* aScope)
+AudioBuffer::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AudioBufferBinding::Wrap(aCx, aScope, this);
 }
 
 void
 AudioBuffer::RestoreJSChannelData(JSContext* aJSContext)
 {
   if (mSharedChannels) {
--- a/content/media/webaudio/AudioBuffer.h
+++ b/content/media/webaudio/AudioBuffer.h
@@ -48,17 +48,18 @@ public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AudioBuffer)
 
   AudioContext* GetParentObject() const
   {
     return mContext;
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   float SampleRate() const
   {
     return mSampleRate;
   }
 
   int32_t Length() const
   {
--- a/content/media/webaudio/AudioBufferSourceNode.cpp
+++ b/content/media/webaudio/AudioBufferSourceNode.cpp
@@ -418,17 +418,17 @@ AudioBufferSourceNode::AudioBufferSource
 AudioBufferSourceNode::~AudioBufferSourceNode()
 {
   if (Context()) {
     Context()->UnregisterAudioBufferSourceNode(this);
   }
 }
 
 JSObject*
-AudioBufferSourceNode::WrapObject(JSContext* aCx, JSObject* aScope)
+AudioBufferSourceNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AudioBufferSourceNodeBinding::Wrap(aCx, aScope, this);
 }
 
 void
 AudioBufferSourceNode::Start(double aWhen, double aOffset,
                              const Optional<double>& aDuration, ErrorResult& aRv)
 {
--- a/content/media/webaudio/AudioBufferSourceNode.h
+++ b/content/media/webaudio/AudioBufferSourceNode.h
@@ -48,17 +48,18 @@ public:
 
   void RegisterPannerNode(PannerNode* aPannerNode) {
     mPannerNode = aPannerNode;
   }
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioBufferSourceNode, AudioNode)
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   void Start(double aWhen, double aOffset,
              const Optional<double>& aDuration, ErrorResult& aRv);
   void NoteOn(double aWhen, ErrorResult& aRv)
   {
     Start(aWhen, 0.0, Optional<double>(), aRv);
   }
   void NoteGrainOn(double aWhen, double aOffset,
--- a/content/media/webaudio/AudioContext.cpp
+++ b/content/media/webaudio/AudioContext.cpp
@@ -50,17 +50,17 @@ AudioContext::AudioContext(nsPIDOMWindow
   mScriptProcessorNodes.Init();
 }
 
 AudioContext::~AudioContext()
 {
 }
 
 JSObject*
-AudioContext::WrapObject(JSContext* aCx, JSObject* aScope)
+AudioContext::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AudioContextBinding::Wrap(aCx, aScope, this);
 }
 
 /* static */ already_AddRefed<AudioContext>
 AudioContext::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
--- a/content/media/webaudio/AudioContext.h
+++ b/content/media/webaudio/AudioContext.h
@@ -65,17 +65,18 @@ public:
   {
     return mWindow;
   }
 
   void Shutdown();
   void Suspend();
   void Resume();
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   static already_AddRefed<AudioContext>
   Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
 
   AudioDestinationNode* Destination() const
   {
     return mDestination;
   }
--- a/content/media/webaudio/AudioDestinationNode.cpp
+++ b/content/media/webaudio/AudioDestinationNode.cpp
@@ -18,15 +18,15 @@ NS_IMPL_ISUPPORTS_INHERITED0(AudioDestin
 AudioDestinationNode::AudioDestinationNode(AudioContext* aContext, MediaStreamGraph* aGraph)
   : AudioNode(aContext)
 {
   mStream = aGraph->CreateAudioNodeStream(new AudioNodeEngine(this),
                                           MediaStreamGraph::EXTERNAL_STREAM);
 }
 
 JSObject*
-AudioDestinationNode::WrapObject(JSContext* aCx, JSObject* aScope)
+AudioDestinationNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AudioDestinationNodeBinding::Wrap(aCx, aScope, this);
 }
 
 }
 }
--- a/content/media/webaudio/AudioDestinationNode.h
+++ b/content/media/webaudio/AudioDestinationNode.h
@@ -16,17 +16,18 @@ class AudioContext;
 
 class AudioDestinationNode : public AudioNode
 {
 public:
   AudioDestinationNode(AudioContext* aContext, MediaStreamGraph* aGraph);
 
   NS_DECL_ISUPPORTS_INHERITED
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual uint32_t NumberOfOutputs() const MOZ_FINAL MOZ_OVERRIDE
   {
     return 0;
   }
 
 };
 
--- a/content/media/webaudio/AudioListener.cpp
+++ b/content/media/webaudio/AudioListener.cpp
@@ -27,17 +27,17 @@ AudioListener::AudioListener(AudioContex
   , mDopplerFactor(1.)
   , mSpeedOfSound(343.3) // meters/second
 {
   MOZ_ASSERT(aContext);
   SetIsDOMBinding();
 }
 
 JSObject*
-AudioListener::WrapObject(JSContext* aCx, JSObject* aScope)
+AudioListener::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AudioListenerBinding::Wrap(aCx, aScope, this);
 }
 
 void
 AudioListener::RegisterPannerNode(PannerNode* aPannerNode)
 {
   mPanners.AppendElement(aPannerNode->asWeakPtr());
--- a/content/media/webaudio/AudioListener.h
+++ b/content/media/webaudio/AudioListener.h
@@ -34,17 +34,18 @@ public:
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AudioListener)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AudioListener)
 
   AudioContext* GetParentObject() const
   {
     return mContext;
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   double DopplerFactor() const
   {
     return mDopplerFactor;
   }
   void SetDopplerFactor(double aDopplerFactor)
   {
     if (WebAudioUtils::FuzzyEqual(mDopplerFactor, aDopplerFactor)) {
--- a/content/media/webaudio/AudioParam.cpp
+++ b/content/media/webaudio/AudioParam.cpp
@@ -29,16 +29,16 @@ AudioParam::AudioParam(AudioNode* aNode,
   SetIsDOMBinding();
 }
 
 AudioParam::~AudioParam()
 {
 }
 
 JSObject*
-AudioParam::WrapObject(JSContext* aCx, JSObject* aScope)
+AudioParam::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AudioParamBinding::Wrap(aCx, aScope, this);
 }
 
 }
 }
 
--- a/content/media/webaudio/AudioParam.h
+++ b/content/media/webaudio/AudioParam.h
@@ -40,17 +40,18 @@ public:
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AudioParam)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AudioParam)
 
   AudioContext* GetParentObject() const
   {
     return mNode->Context();
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // We override SetValueCurveAtTime to convert the Float32Array to the wrapper
   // object.
   void SetValueCurveAtTime(JSContext* cx, const Float32Array& aValues, double aStartTime, double aDuration, ErrorResult& aRv)
   {
     AudioParamTimeline::SetValueCurveAtTime(aValues.Data(), aValues.Length(),
                                             aStartTime, aDuration, aRv);
     mCallback(mNode);
--- a/content/media/webaudio/AudioProcessingEvent.cpp
+++ b/content/media/webaudio/AudioProcessingEvent.cpp
@@ -25,17 +25,17 @@ AudioProcessingEvent::AudioProcessingEve
   : nsDOMEvent(aOwner, aPresContext, aEvent)
   , mPlaybackTime(0.0)
   , mNode(aOwner)
 {
   SetIsDOMBinding();
 }
 
 JSObject*
-AudioProcessingEvent::WrapObject(JSContext* aCx, JSObject* aScope)
+AudioProcessingEvent::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AudioProcessingEventBinding::Wrap(aCx, aScope, this);
 }
 
 void
 AudioProcessingEvent::LazilyCreateBuffer(nsRefPtr<AudioBuffer>& aBuffer,
                                          uint32_t aNumberOfChannels)
 {
--- a/content/media/webaudio/AudioProcessingEvent.h
+++ b/content/media/webaudio/AudioProcessingEvent.h
@@ -21,17 +21,18 @@ public:
   AudioProcessingEvent(ScriptProcessorNode* aOwner,
                        nsPresContext *aPresContext,
                        nsEvent *aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_TO_NSDOMEVENT
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioProcessingEvent, nsDOMEvent)
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   void InitEvent(AudioBuffer* aInputBuffer,
                  uint32_t aNumberOfInputChannels,
                  double aPlaybackTime)
   {
     InitEvent(NS_LITERAL_STRING("audioprocess"), false, false);
     mInputBuffer = aInputBuffer;
     mNumberOfInputChannels = aNumberOfInputChannels;
--- a/content/media/webaudio/BiquadFilterNode.cpp
+++ b/content/media/webaudio/BiquadFilterNode.cpp
@@ -105,17 +105,17 @@ BiquadFilterNode::BiquadFilterNode(Audio
   , mGain(new AudioParam(this, SendGainToStream, 0.f))
 {
   BiquadFilterNodeEngine* engine = new BiquadFilterNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
   engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
 }
 
 JSObject*
-BiquadFilterNode::WrapObject(JSContext* aCx, JSObject* aScope)
+BiquadFilterNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return BiquadFilterNodeBinding::Wrap(aCx, aScope, this);
 }
 
 void
 BiquadFilterNode::SetType(uint16_t aType, ErrorResult& aRv)
 {
   BiquadTypeEnum type = static_cast<BiquadTypeEnum> (aType);
--- a/content/media/webaudio/BiquadFilterNode.h
+++ b/content/media/webaudio/BiquadFilterNode.h
@@ -32,17 +32,18 @@ MOZ_END_ENUM_CLASS(BiquadTypeEnum)
 class BiquadFilterNode : public AudioNode
 {
 public:
   explicit BiquadFilterNode(AudioContext* aContext);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BiquadFilterNode, AudioNode)
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual bool SupportsMediaStreams() const MOZ_OVERRIDE
   {
     return true;
   }
 
   uint16_t Type() const
   {
--- a/content/media/webaudio/DelayNode.cpp
+++ b/content/media/webaudio/DelayNode.cpp
@@ -277,17 +277,17 @@ DelayNode::DelayNode(AudioContext* aCont
   DelayNodeEngine* engine = new DelayNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
   engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
   AudioNodeStream* ns = static_cast<AudioNodeStream*>(mStream.get());
   ns->SetDoubleParameter(DelayNodeEngine::MAX_DELAY, aMaxDelay);
 }
 
 JSObject*
-DelayNode::WrapObject(JSContext* aCx, JSObject* aScope)
+DelayNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return DelayNodeBinding::Wrap(aCx, aScope, this);
 }
 
 void
 DelayNode::SendDelayToStream(AudioNode* aNode)
 {
   DelayNode* This = static_cast<DelayNode*>(aNode);
--- a/content/media/webaudio/DelayNode.h
+++ b/content/media/webaudio/DelayNode.h
@@ -18,17 +18,18 @@ class AudioContext;
 class DelayNode : public AudioNode
 {
 public:
   DelayNode(AudioContext* aContext, double aMaxDelay);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DelayNode, AudioNode)
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   AudioParam* DelayTime() const
   {
     return mDelay;
   }
 
   virtual bool SupportsMediaStreams() const MOZ_OVERRIDE
   {
--- a/content/media/webaudio/DynamicsCompressorNode.cpp
+++ b/content/media/webaudio/DynamicsCompressorNode.cpp
@@ -187,17 +187,17 @@ DynamicsCompressorNode::DynamicsCompress
 {
   DynamicsCompressorNodeEngine* engine = new DynamicsCompressorNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM,
                                                      DEFAULT_NUMBER_OF_CHANNELS);
   engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
 }
 
 JSObject*
-DynamicsCompressorNode::WrapObject(JSContext* aCx, JSObject* aScope)
+DynamicsCompressorNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return DynamicsCompressorNodeBinding::Wrap(aCx, aScope, this);
 }
 
 void
 DynamicsCompressorNode::SendThresholdToStream(AudioNode* aNode)
 {
   DynamicsCompressorNode* This = static_cast<DynamicsCompressorNode*>(aNode);
--- a/content/media/webaudio/DynamicsCompressorNode.h
+++ b/content/media/webaudio/DynamicsCompressorNode.h
@@ -18,17 +18,18 @@ class AudioContext;
 class DynamicsCompressorNode : public AudioNode
 {
 public:
   explicit DynamicsCompressorNode(AudioContext* aContext);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DynamicsCompressorNode, AudioNode)
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual bool SupportsMediaStreams() const MOZ_OVERRIDE
   {
     return true;
   }
 
   AudioParam* Threshold() const
   {
--- a/content/media/webaudio/GainNode.cpp
+++ b/content/media/webaudio/GainNode.cpp
@@ -99,17 +99,17 @@ GainNode::GainNode(AudioContext* aContex
   , mGain(new AudioParam(this, SendGainToStream, 1.0f))
 {
   GainNodeEngine* engine = new GainNodeEngine(this, aContext->Destination());
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
   engine->SetSourceStream(static_cast<AudioNodeStream*> (mStream.get()));
 }
 
 JSObject*
-GainNode::WrapObject(JSContext* aCx, JSObject* aScope)
+GainNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return GainNodeBinding::Wrap(aCx, aScope, this);
 }
 
 void
 GainNode::SendGainToStream(AudioNode* aNode)
 {
   GainNode* This = static_cast<GainNode*>(aNode);
--- a/content/media/webaudio/GainNode.h
+++ b/content/media/webaudio/GainNode.h
@@ -18,17 +18,18 @@ class AudioContext;
 class GainNode : public AudioNode
 {
 public:
   explicit GainNode(AudioContext* aContext);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(GainNode, AudioNode)
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   AudioParam* Gain() const
   {
     return mGain;
   }
 
   virtual bool SupportsMediaStreams() const MOZ_OVERRIDE
   {
--- a/content/media/webaudio/PannerNode.cpp
+++ b/content/media/webaudio/PannerNode.cpp
@@ -182,17 +182,17 @@ PannerNode::PannerNode(AudioContext* aCo
 PannerNode::~PannerNode()
 {
   if (Context()) {
     Context()->UnregisterPannerNode(this);
   }
 }
 
 JSObject*
-PannerNode::WrapObject(JSContext* aCx, JSObject* aScope)
+PannerNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return PannerNodeBinding::Wrap(aCx, aScope, this);
 }
 
 // Those three functions are described in the spec.
 float
 PannerNodeEngine::LinearGainFunction(float aDistance)
 {
--- a/content/media/webaudio/PannerNode.h
+++ b/content/media/webaudio/PannerNode.h
@@ -25,17 +25,18 @@ class AudioBufferSourceNode;
 
 class PannerNode : public AudioNode,
                    public SupportsWeakPtr<PannerNode>
 {
 public:
   explicit PannerNode(AudioContext* aContext);
   virtual ~PannerNode();
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual bool SupportsMediaStreams() const MOZ_OVERRIDE
   {
     return true;
   }
 
   PanningModelType PanningModel() const
   {
--- a/content/media/webaudio/ScriptProcessorNode.cpp
+++ b/content/media/webaudio/ScriptProcessorNode.cpp
@@ -380,16 +380,16 @@ ScriptProcessorNode::ScriptProcessorNode
 ScriptProcessorNode::~ScriptProcessorNode()
 {
   if (Context()) {
     Context()->UnregisterScriptProcessorNode(this);
   }
 }
 
 JSObject*
-ScriptProcessorNode::WrapObject(JSContext* aCx, JSObject* aScope)
+ScriptProcessorNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return ScriptProcessorNodeBinding::Wrap(aCx, aScope, this);
 }
 
 }
 }
 
--- a/content/media/webaudio/ScriptProcessorNode.h
+++ b/content/media/webaudio/ScriptProcessorNode.h
@@ -29,17 +29,18 @@ public:
                       uint32_t aNumberOfOutputChannels);
   virtual ~ScriptProcessorNode();
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ScriptProcessorNode, AudioNode)
 
   IMPL_EVENT_HANDLER(audioprocess)
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual bool SupportsMediaStreams() const MOZ_OVERRIDE
   {
     return true;
   }
 
   virtual void Connect(AudioNode& aDestination, uint32_t aOutput,
                        uint32_t aInput, ErrorResult& aRv) MOZ_OVERRIDE
--- a/content/media/webspeech/recognition/SpeechGrammar.cpp
+++ b/content/media/webspeech/recognition/SpeechGrammar.cpp
@@ -40,17 +40,17 @@ SpeechGrammar::Constructor(const GlobalO
 
 nsISupports*
 SpeechGrammar::GetParentObject() const
 {
   return mParent;
 }
 
 JSObject*
-SpeechGrammar::WrapObject(JSContext* aCx, JSObject* aScope)
+SpeechGrammar::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SpeechGrammarBinding::Wrap(aCx, aScope, this);
 }
 
 void
 SpeechGrammar::GetSrc(nsString& aRetVal, ErrorResult& aRv) const
 {
   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
--- a/content/media/webspeech/recognition/SpeechGrammar.h
+++ b/content/media/webspeech/recognition/SpeechGrammar.h
@@ -31,17 +31,18 @@ public:
   SpeechGrammar(nsISupports* aParent);
   ~SpeechGrammar();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechGrammar)
 
   nsISupports* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   static SpeechGrammar* Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
 
   void GetSrc(nsString& aRetVal, ErrorResult& aRv) const;
 
   void SetSrc(const nsAString& aArg, ErrorResult& aRv);
 
   float GetWeight(ErrorResult& aRv) const;
--- a/content/media/webspeech/recognition/SpeechGrammarList.cpp
+++ b/content/media/webspeech/recognition/SpeechGrammarList.cpp
@@ -33,17 +33,17 @@ SpeechGrammarList::~SpeechGrammarList()
 
 SpeechGrammarList*
 SpeechGrammarList::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
 {
   return new SpeechGrammarList(aGlobal.Get());
 }
 
 JSObject*
-SpeechGrammarList::WrapObject(JSContext* aCx, JSObject* aScope)
+SpeechGrammarList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SpeechGrammarListBinding::Wrap(aCx, aScope, this);
 }
 
 nsISupports*
 SpeechGrammarList::GetParentObject() const
 {
   return mParent;
--- a/content/media/webspeech/recognition/SpeechGrammarList.h
+++ b/content/media/webspeech/recognition/SpeechGrammarList.h
@@ -32,17 +32,18 @@ public:
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechGrammarList)
 
   SpeechGrammarList* Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
 
   nsISupports* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   uint32_t Length() const;
 
   already_AddRefed<SpeechGrammar> Item(uint32_t aIndex, ErrorResult& aRv);
 
   void AddFromURI(const nsAString& aSrc, const Optional<float>& aWeight, ErrorResult& aRv);
 
   void AddFromString(const nsAString& aString, const Optional<float>& aWeight, ErrorResult& aRv);
--- a/content/media/webspeech/recognition/SpeechRecognition.cpp
+++ b/content/media/webspeech/recognition/SpeechRecognition.cpp
@@ -97,17 +97,17 @@ void
 SpeechRecognition::SetState(FSMState state)
 {
   mCurrentState = state;
   SR_LOG("Transitioned to state %s", GetName(mCurrentState));
   return;
 }
 
 JSObject*
-SpeechRecognition::WrapObject(JSContext* aCx, JSObject* aScope)
+SpeechRecognition::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SpeechRecognitionBinding::Wrap(aCx, aScope, this);
 }
 
 already_AddRefed<SpeechRecognition>
 SpeechRecognition::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
--- a/content/media/webspeech/recognition/SpeechRecognition.h
+++ b/content/media/webspeech/recognition/SpeechRecognition.h
@@ -62,17 +62,18 @@ public:
   virtual ~SpeechRecognition() {};
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIOBSERVER
 
   nsISupports* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   static already_AddRefed<SpeechRecognition> Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
 
   already_AddRefed<SpeechGrammarList> GetGrammars(ErrorResult& aRv) const;
 
   void SetGrammars(mozilla::dom::SpeechGrammarList& aArg, ErrorResult& aRv);
 
   void GetLang(nsString& aRetVal, ErrorResult& aRv) const;
--- a/content/media/webspeech/recognition/SpeechRecognitionAlternative.cpp
+++ b/content/media/webspeech/recognition/SpeechRecognitionAlternative.cpp
@@ -31,17 +31,18 @@ SpeechRecognitionAlternative::SpeechReco
   SetIsDOMBinding();
 }
 
 SpeechRecognitionAlternative::~SpeechRecognitionAlternative()
 {
 }
 
 JSObject*
-SpeechRecognitionAlternative::WrapObject(JSContext* aCx, JSObject* aScope)
+SpeechRecognitionAlternative::WrapObject(JSContext* aCx,
+                                         JS::Handle<JSObject*> aScope)
 {
   return SpeechRecognitionAlternativeBinding::Wrap(aCx, aScope, this);
 }
 
 nsISupports*
 SpeechRecognitionAlternative::GetParentObject() const
 {
   return static_cast<nsDOMEventTargetHelper*>(mParent.get());
--- a/content/media/webspeech/recognition/SpeechRecognitionAlternative.h
+++ b/content/media/webspeech/recognition/SpeechRecognitionAlternative.h
@@ -30,17 +30,18 @@ public:
   SpeechRecognitionAlternative(SpeechRecognition* aParent);
   ~SpeechRecognitionAlternative();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechRecognitionAlternative)
 
   nsISupports* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   void GetTranscript(nsString& aRetVal) const;
 
   float Confidence() const;
 
   nsString mTranscript;
   float mConfidence;
 private:
--- a/content/media/webspeech/recognition/SpeechRecognitionResult.cpp
+++ b/content/media/webspeech/recognition/SpeechRecognitionResult.cpp
@@ -28,17 +28,18 @@ SpeechRecognitionResult::SpeechRecogniti
   SetIsDOMBinding();
 }
 
 SpeechRecognitionResult::~SpeechRecognitionResult()
 {
 }
 
 JSObject*
-SpeechRecognitionResult::WrapObject(JSContext* aCx, JSObject* aScope)
+SpeechRecognitionResult::WrapObject(JSContext* aCx,
+                                    JS::Handle<JSObject*> aScope)
 {
   return SpeechRecognitionResultBinding::Wrap(aCx, aScope, this);
 }
 
 nsISupports*
 SpeechRecognitionResult::GetParentObject() const
 {
   return static_cast<nsDOMEventTargetHelper*>(mParent.get());
--- a/content/media/webspeech/recognition/SpeechRecognitionResult.h
+++ b/content/media/webspeech/recognition/SpeechRecognitionResult.h
@@ -30,17 +30,18 @@ public:
   SpeechRecognitionResult(SpeechRecognition* aParent);
   ~SpeechRecognitionResult();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechRecognitionResult)
 
   nsISupports* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   uint32_t Length() const;
 
   already_AddRefed<SpeechRecognitionAlternative> Item(uint32_t aIndex);
 
   bool Final() const;
 
   already_AddRefed<SpeechRecognitionAlternative> IndexedGetter(uint32_t aIndex, bool& aPresent);
--- a/content/media/webspeech/recognition/SpeechRecognitionResultList.cpp
+++ b/content/media/webspeech/recognition/SpeechRecognitionResultList.cpp
@@ -35,17 +35,18 @@ SpeechRecognitionResultList::~SpeechReco
 
 nsISupports*
 SpeechRecognitionResultList::GetParentObject() const
 {
   return static_cast<nsDOMEventTargetHelper*>(mParent.get());
 }
 
 JSObject*
-SpeechRecognitionResultList::WrapObject(JSContext* aCx, JSObject* aScope)
+SpeechRecognitionResultList::WrapObject(JSContext* aCx,
+                                        JS::Handle<JSObject*> aScope)
 {
   return SpeechRecognitionResultListBinding::Wrap(aCx, aScope, this);
 }
 
 already_AddRefed<SpeechRecognitionResult>
 SpeechRecognitionResultList::IndexedGetter(uint32_t aIndex, bool& aPresent)
 {
   if (aIndex >= Length()) {
--- a/content/media/webspeech/recognition/SpeechRecognitionResultList.h
+++ b/content/media/webspeech/recognition/SpeechRecognitionResultList.h
@@ -31,17 +31,18 @@ public:
   SpeechRecognitionResultList(SpeechRecognition* aParent);
   ~SpeechRecognitionResultList();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechRecognitionResultList)
 
   nsISupports* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   uint32_t Length() const;
 
   already_AddRefed<SpeechRecognitionResult> Item(uint32_t aIndex);
 
   already_AddRefed<SpeechRecognitionResult> IndexedGetter(uint32_t aIndex, bool& aPresent);
 
   nsTArray<nsRefPtr<SpeechRecognitionResult> > mItems;
--- a/content/media/webspeech/synth/SpeechSynthesis.cpp
+++ b/content/media/webspeech/synth/SpeechSynthesis.cpp
@@ -77,17 +77,17 @@ SpeechSynthesis::SpeechSynthesis(nsPIDOM
 }
 
 SpeechSynthesis::~SpeechSynthesis()
 {
   mVoiceCache.Clear();
 }
 
 JSObject*
-SpeechSynthesis::WrapObject(JSContext* aCx, JSObject* aScope)
+SpeechSynthesis::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SpeechSynthesisBinding::Wrap(aCx, aScope, this);
 }
 
 nsIDOMWindow*
 SpeechSynthesis::GetParentObject() const
 {
   return mParent;
--- a/content/media/webspeech/synth/SpeechSynthesis.h
+++ b/content/media/webspeech/synth/SpeechSynthesis.h
@@ -31,17 +31,18 @@ public:
   SpeechSynthesis(nsPIDOMWindow* aParent);
   virtual ~SpeechSynthesis();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechSynthesis)
 
   nsIDOMWindow* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   bool Pending() const;
 
   bool Speaking() const;
 
   bool Paused() const;
 
   void Speak(SpeechSynthesisUtterance& aUtterance);
--- a/content/media/webspeech/synth/SpeechSynthesisUtterance.cpp
+++ b/content/media/webspeech/synth/SpeechSynthesisUtterance.cpp
@@ -35,17 +35,18 @@ SpeechSynthesisUtterance::SpeechSynthesi
   , mPaused(false)
 {
   SetIsDOMBinding();
 }
 
 SpeechSynthesisUtterance::~SpeechSynthesisUtterance() {}
 
 JSObject*
-SpeechSynthesisUtterance::WrapObject(JSContext* aCx, JSObject* aScope)
+SpeechSynthesisUtterance::WrapObject(JSContext* aCx,
+                                     JS::Handle<JSObject*> aScope)
 {
   return SpeechSynthesisUtteranceBinding::Wrap(aCx, aScope, this);
 }
 
 nsISupports*
 SpeechSynthesisUtterance::GetParentObject() const
 {
   return GetOwner();
--- a/content/media/webspeech/synth/SpeechSynthesisUtterance.h
+++ b/content/media/webspeech/synth/SpeechSynthesisUtterance.h
@@ -34,17 +34,18 @@ public:
   virtual ~SpeechSynthesisUtterance();
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
 
   nsISupports* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   static
   already_AddRefed<SpeechSynthesisUtterance> Constructor(GlobalObject& aGlobal,
                                                          ErrorResult& aRv);
   static
   already_AddRefed<SpeechSynthesisUtterance> Constructor(GlobalObject& aGlobal,
                                                          const nsAString& aText,
                                                          ErrorResult& aRv);
--- a/content/media/webspeech/synth/SpeechSynthesisVoice.cpp
+++ b/content/media/webspeech/synth/SpeechSynthesisVoice.cpp
@@ -27,17 +27,17 @@ SpeechSynthesisVoice::SpeechSynthesisVoi
   SetIsDOMBinding();
 }
 
 SpeechSynthesisVoice::~SpeechSynthesisVoice()
 {
 }
 
 JSObject*
-SpeechSynthesisVoice::WrapObject(JSContext* aCx, JSObject* aScope)
+SpeechSynthesisVoice::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SpeechSynthesisVoiceBinding::Wrap(aCx, aScope, this);
 }
 
 nsISupports*
 SpeechSynthesisVoice::GetParentObject() const
 {
   return mParent;
--- a/content/media/webspeech/synth/SpeechSynthesisVoice.h
+++ b/content/media/webspeech/synth/SpeechSynthesisVoice.h
@@ -33,17 +33,18 @@ public:
 
   virtual ~SpeechSynthesisVoice();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechSynthesisVoice)
 
   nsISupports* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   void GetVoiceURI(nsString& aRetval) const;
 
   void GetName(nsString& aRetval) const;
 
   void GetLang(nsString& aRetval) const;
 
   bool LocalService() const;
--- a/content/svg/content/src/DOMSVGAnimatedLengthList.cpp
+++ b/content/svg/content/src/DOMSVGAnimatedLengthList.cpp
@@ -25,17 +25,17 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGAn
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGAnimatedLengthList)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGAnimatedLengthList)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 JSObject*
-DOMSVGAnimatedLengthList::WrapObject(JSContext* aCx, JSObject* aScope)
+DOMSVGAnimatedLengthList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return dom::SVGAnimatedLengthListBinding::Wrap(aCx, aScope, this);
 }
 
 already_AddRefed<DOMSVGLengthList>
 DOMSVGAnimatedLengthList::BaseVal()
 {
   if (!mBaseVal) {
--- a/content/svg/content/src/DOMSVGAnimatedLengthList.h
+++ b/content/svg/content/src/DOMSVGAnimatedLengthList.h
@@ -155,17 +155,18 @@ public:
   /**
    * Returns true if our attribute is animating (in which case our animVal is
    * not simply a mirror of our baseVal).
    */
   bool IsAnimating() const;
 
   // WebIDL
   nsSVGElement* GetParentObject() const { return mElement; }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
   // These aren't weak refs because mBaseVal and mAnimVal are weak
   already_AddRefed<DOMSVGLengthList> BaseVal();
   already_AddRefed<DOMSVGLengthList> AnimVal();
 
 private:
 
   /**
    * Only our static GetDOMWrapper() factory method may create objects of our
--- a/content/svg/content/src/DOMSVGAnimatedNumberList.cpp
+++ b/content/svg/content/src/DOMSVGAnimatedNumberList.cpp
@@ -25,17 +25,17 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGAn
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGAnimatedNumberList)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGAnimatedNumberList)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 JSObject*
-DOMSVGAnimatedNumberList::WrapObject(JSContext* aCx, JSObject* aScope)
+DOMSVGAnimatedNumberList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return mozilla::dom::SVGAnimatedNumberListBinding::Wrap(aCx, aScope, this);
 }
 
 already_AddRefed<DOMSVGNumberList>
 DOMSVGAnimatedNumberList::BaseVal()
 {
   if (!mBaseVal) {
--- a/content/svg/content/src/DOMSVGAnimatedNumberList.h
+++ b/content/svg/content/src/DOMSVGAnimatedNumberList.h
@@ -85,17 +85,18 @@ public:
   /**
    * Returns true if our attribute is animating (in which case our animVal is
    * not simply a mirror of our baseVal).
    */
   bool IsAnimating() const;
 
   // WebIDL
   nsSVGElement* GetParentObject() const { return mElement; }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
   // These aren't weak refs because mBaseVal and mAnimVal are weak
   already_AddRefed<DOMSVGNumberList> BaseVal();
   already_AddRefed<DOMSVGNumberList> AnimVal();
 
 private:
 
   /**
    * Only our static GetDOMWrapper() factory method may create objects of our
--- a/content/svg/content/src/DOMSVGLengthList.cpp
+++ b/content/svg/content/src/DOMSVGLengthList.cpp
@@ -63,17 +63,17 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGLe
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGLengthList)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGLengthList)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 JSObject*
-DOMSVGLengthList::WrapObject(JSContext *cx, JSObject *scope)
+DOMSVGLengthList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return mozilla::dom::SVGLengthListBinding::Wrap(cx, scope, this);
 }
 
 void
 DOMSVGLengthList::InternalListLengthWillChange(uint32_t aNewLength)
 {
   uint32_t oldLength = mItems.Length();
--- a/content/svg/content/src/DOMSVGLengthList.h
+++ b/content/svg/content/src/DOMSVGLengthList.h
@@ -66,17 +66,18 @@ public:
     // Our mAList's weak ref to us must be nulled out when we die. If GC has
     // unlinked us using the cycle collector code, then that has already
     // happened, and mAList is null.
     if (mAList) {
       ( IsAnimValList() ? mAList->mAnimVal : mAList->mBaseVal ) = nullptr;
     }
   }
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   nsISupports* GetParentObject()
   {
     return static_cast<nsIContent*>(Element());
   }
 
   /**
    * This will normally be the same as InternalList().Length(), except if we've
--- a/content/svg/content/src/DOMSVGNumberList.cpp
+++ b/content/svg/content/src/DOMSVGNumberList.cpp
@@ -64,17 +64,17 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGN
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGNumberList)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 
 JSObject*
-DOMSVGNumberList::WrapObject(JSContext *cx, JSObject *scope)
+DOMSVGNumberList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return mozilla::dom::SVGNumberListBinding::Wrap(cx, scope, this);
 }
 
 void
 DOMSVGNumberList::InternalListLengthWillChange(uint32_t aNewLength)
 {
   uint32_t oldLength = mItems.Length();
--- a/content/svg/content/src/DOMSVGNumberList.h
+++ b/content/svg/content/src/DOMSVGNumberList.h
@@ -66,17 +66,18 @@ public:
     // Our mAList's weak ref to us must be nulled out when we die. If GC has
     // unlinked us using the cycle collector code, then that has already
     // happened, and mAList is null.
     if (mAList) {
       ( IsAnimValList() ? mAList->mAnimVal : mAList->mBaseVal ) = nullptr;
     }
   }
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   nsISupports* GetParentObject()
   {
     return static_cast<nsIContent*>(Element());
   }
 
   /**
    * This will normally be the same as InternalList().Length(), except if we've
--- a/content/svg/content/src/DOMSVGPathSeg.h
+++ b/content/svg/content/src/DOMSVGPathSeg.h
@@ -63,17 +63,17 @@ namespace mozilla {
   }                                                                           \
   virtual float*                                                              \
   PtrToMemberArgs()                                                           \
   {                                                                           \
     return mArgs;                                                             \
   }                                                                           \
                                                                               \
   virtual JSObject*                                                           \
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE                   \
+  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE       \
   {                                                                           \
     return dom::SVGPathSeg##segName##Binding::Wrap(aCx, aScope, this);        \
   }
 
 
 /**
  * Class DOMSVGPathSeg
  *
@@ -170,17 +170,18 @@ public:
    */
   virtual uint32_t Type() const = 0;
 
   // WebIDL
   DOMSVGPathSegList* GetParentObject() { return mList; }
   uint16_t PathSegType() const { return Type(); }
   void GetPathSegTypeAsLetter(nsAString &aPathSegTypeAsLetter)
     { aPathSegTypeAsLetter = SVGPathSegUtils::GetPathSegTypeAsLetter(Type()); }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE = 0;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE = 0;
 
 protected:
 
   /**
    * Generic ctor for DOMSVGPathSeg objects that are created for an attribute.
    */
   DOMSVGPathSeg(DOMSVGPathSegList *aList,
                 uint32_t aListIndex,
--- a/content/svg/content/src/DOMSVGPathSegList.cpp
+++ b/content/svg/content/src/DOMSVGPathSegList.cpp
@@ -69,17 +69,17 @@ DOMSVGPathSegList::~DOMSVGPathSegList()
   // Note we must use GetAnimValKey/GetBaseValKey here, NOT InternalList()!
   void *key = mIsAnimValList ?
     InternalAList().GetAnimValKey() :
     InternalAList().GetBaseValKey();
   sSVGPathSegListTearoffTable.RemoveTearoff(key);
 }
 
 JSObject*
-DOMSVGPathSegList::WrapObject(JSContext *cx, JSObject *scope)
+DOMSVGPathSegList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return mozilla::dom::SVGPathSegListBinding::Wrap(cx, scope, this);
 }
 
 void
 DOMSVGPathSegList::InternalListWillChangeTo(const SVGPathData& aNewValue)
 {
   // When the number of items in our internal counterpart changes, we MUST stay
--- a/content/svg/content/src/DOMSVGPathSegList.h
+++ b/content/svg/content/src/DOMSVGPathSegList.h
@@ -50,17 +50,18 @@ class DOMSVGPathSegList MOZ_FINAL : publ
                                     public nsWrapperCache
 {
   friend class DOMSVGPathSeg;
 
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMSVGPathSegList)
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   nsISupports* GetParentObject()
   {
     return static_cast<nsIContent*>(mElement);
   }
 
   /**
    * Factory method to create and return a DOMSVGPathSegList wrapper
--- a/content/svg/content/src/DOMSVGPointList.cpp
+++ b/content/svg/content/src/DOMSVGPointList.cpp
@@ -87,17 +87,17 @@ DOMSVGPointList::~DOMSVGPointList()
   // Note we must use GetAnimValKey/GetBaseValKey here, NOT InternalList()!
   void *key = mIsAnimValList ?
     InternalAList().GetAnimValKey() :
     InternalAList().GetBaseValKey();
   sSVGPointListTearoffTable.RemoveTearoff(key);
 }
 
 JSObject*
-DOMSVGPointList::WrapObject(JSContext *cx, JSObject *scope)
+DOMSVGPointList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return mozilla::dom::SVGPointListBinding::Wrap(cx, scope, this);
 }
 
 void
 DOMSVGPointList::InternalListWillChangeTo(const SVGPointList& aNewValue)
 {
   // When the number of items in our internal counterpart changes, we MUST stay
--- a/content/svg/content/src/DOMSVGPointList.h
+++ b/content/svg/content/src/DOMSVGPointList.h
@@ -52,17 +52,18 @@ class DOMSVGPointList MOZ_FINAL : public
 {
   friend class nsISVGPoint;
   friend class mozilla::DOMSVGPoint;
 
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMSVGPointList)
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   nsISupports* GetParentObject()
   {
     return static_cast<nsIContent*>(mElement);
   }
 
   /**
    * Factory method to create and return a DOMSVGPointList wrapper
--- a/content/svg/content/src/DOMSVGStringList.cpp
+++ b/content/svg/content/src/DOMSVGStringList.cpp
@@ -46,17 +46,17 @@ DOMSVGStringList::GetDOMWrapper(SVGStrin
 
 DOMSVGStringList::~DOMSVGStringList()
 {
   // Script no longer has any references to us.
   sSVGStringListTearoffTable.RemoveTearoff(&InternalList());
 }
 
 /* virtual */ JSObject*
-DOMSVGStringList::WrapObject(JSContext* aCx, JSObject* aScope)
+DOMSVGStringList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SVGStringListBinding::Wrap(aCx, aScope, this);
 }
 
 // ----------------------------------------------------------------------------
 // SVGStringList implementation:
 
 uint32_t
--- a/content/svg/content/src/DOMSVGStringList.h
+++ b/content/svg/content/src/DOMSVGStringList.h
@@ -48,17 +48,18 @@ class DOMSVGStringList MOZ_FINAL : publi
 public:
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMSVGStringList)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMSVGStringList)
 
   nsSVGElement* GetParentObject() const
   {
     return mElement;
   }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   uint32_t NumberOfItems() const;
   uint32_t Length() const;
   void Clear();
   void Initialize(const nsAString& aNewItem, nsAString& aRetval,
                   ErrorResult& aRv);
   void GetItem(uint32_t aIndex, nsAString& aRetval, ErrorResult& aRv);
   void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aRetval);
--- a/content/svg/content/src/DOMSVGTransformList.cpp
+++ b/content/svg/content/src/DOMSVGTransformList.cpp
@@ -65,17 +65,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 //----------------------------------------------------------------------
 // DOMSVGTransformList methods:
 
 JSObject*
-DOMSVGTransformList::WrapObject(JSContext *cx, JSObject *scope)
+DOMSVGTransformList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return mozilla::dom::SVGTransformListBinding::Wrap(cx, scope, this);
 }
 
 void
 DOMSVGTransformList::InternalListLengthWillChange(uint32_t aNewLength)
 {
   uint32_t oldLength = mItems.Length();
--- a/content/svg/content/src/DOMSVGTransformList.h
+++ b/content/svg/content/src/DOMSVGTransformList.h
@@ -60,17 +60,18 @@ public:
     // Our mAList's weak ref to us must be nulled out when we die. If GC has
     // unlinked us using the cycle collector code, then that has already
     // happened, and mAList is null.
     if (mAList) {
       ( IsAnimValList() ? mAList->mAnimVal : mAList->mBaseVal ) = nullptr;
     }
   }
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   nsISupports* GetParentObject()
   {
     return static_cast<nsIContent*>(Element());
   }
 
   /**
    * This will normally be the same as InternalList().Length(), except if we've
--- a/content/svg/content/src/SVGAngle.cpp
+++ b/content/svg/content/src/SVGAngle.cpp
@@ -18,17 +18,17 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGAngl
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGAngle)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(SVGAngle)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 JSObject*
-SVGAngle::WrapObject(JSContext* aCx, JSObject* aScope)
+SVGAngle::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SVGAngleBinding::Wrap(aCx, aScope, this);
 }
 
 uint16_t
 SVGAngle::UnitType() const
 {
   if (mType == AnimValue) {
--- a/content/svg/content/src/SVGAngle.h
+++ b/content/svg/content/src/SVGAngle.h
@@ -43,17 +43,18 @@ public:
   {
     SetIsDOMBinding();
   }
 
   ~SVGAngle();
 
   // WebIDL
   nsSVGElement* GetParentObject() { return mSVGElement; }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
   uint16_t UnitType() const;
   float Value() const;
   void GetValueAsString(nsAString& aValue);
   void SetValue(float aValue, ErrorResult& rv);
   float ValueInSpecifiedUnits() const;
   void SetValueInSpecifiedUnits(float aValue, ErrorResult& rv);
   void SetValueAsString(const nsAString& aValue, ErrorResult& rv);
   void NewValueSpecifiedUnits(uint16_t unitType, float value, ErrorResult& rv);
--- a/content/svg/content/src/SVGAnimatedAngle.cpp
+++ b/content/svg/content/src/SVGAnimatedAngle.cpp
@@ -17,17 +17,17 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(SVGAnima
 NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGAnimatedAngle)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGAnimatedAngle)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 JSObject*
-SVGAnimatedAngle::WrapObject(JSContext* aCx, JSObject* aScope)
+SVGAnimatedAngle::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SVGAnimatedAngleBinding::Wrap(aCx, aScope, this);
 }
 
 already_AddRefed<SVGAngle>
 SVGAnimatedAngle::BaseVal()
 {
   return mVal->ToDOMBaseVal(mSVGElement);
--- a/content/svg/content/src/SVGAnimatedAngle.h
+++ b/content/svg/content/src/SVGAnimatedAngle.h
@@ -28,17 +28,18 @@ public:
     : mVal(aVal), mSVGElement(aSVGElement)
   {
     SetIsDOMBinding();
   }
   ~SVGAnimatedAngle();
 
   // WebIDL
   nsSVGElement* GetParentObject() { return mSVGElement; }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
   already_AddRefed<SVGAngle> BaseVal();
   already_AddRefed<SVGAngle> AnimVal();
 
 protected:
   nsSVGAngle* mVal; // kept alive because it belongs to content
   nsRefPtr<nsSVGElement> mSVGElement;
 };
 
--- a/content/svg/content/src/SVGAnimatedBoolean.cpp
+++ b/content/svg/content/src/SVGAnimatedBoolean.cpp
@@ -16,13 +16,13 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(SVGAnima
 NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGAnimatedBoolean)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGAnimatedBoolean)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 JSObject*
-SVGAnimatedBoolean::WrapObject(JSContext* aCx, JSObject* aScope)
+SVGAnimatedBoolean::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SVGAnimatedBooleanBinding::Wrap(aCx, aScope, this);
 }
 
--- a/content/svg/content/src/SVGAnimatedBoolean.h
+++ b/content/svg/content/src/SVGAnimatedBoolean.h
@@ -23,17 +23,18 @@ class SVGAnimatedBoolean MOZ_FINAL : pub
     : mVal(aVal), mSVGElement(aSVGElement)
   {
     SetIsDOMBinding();
   }
   ~SVGAnimatedBoolean();
 
  // WebIDL
   nsSVGElement* GetParentObject() const { return mSVGElement; }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
   bool BaseVal() const { return mVal->GetBaseValue(); }
   void SetBaseVal(bool aValue) { mVal->SetBaseValue(aValue, mSVGElement); }
   bool AnimVal() const { mSVGElement->FlushAnimations(); return mVal->GetAnimValue(); }
 
 protected:
   nsSVGBoolean* mVal; // kept alive because it belongs to content
   nsRefPtr<nsSVGElement> mSVGElement;
 };
--- a/content/svg/content/src/SVGAnimatedLength.cpp
+++ b/content/svg/content/src/SVGAnimatedLength.cpp
@@ -18,17 +18,17 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGAnim
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGAnimatedLength)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedLength)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 JSObject*
-SVGAnimatedLength::WrapObject(JSContext* aCx, JSObject* aScope)
+SVGAnimatedLength::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SVGAnimatedLengthBinding::Wrap(aCx, aScope, this);
 }
 
 already_AddRefed<nsIDOMSVGLength>
 SVGAnimatedLength::BaseVal()
 {
   nsRefPtr<nsIDOMSVGLength> angle;
--- a/content/svg/content/src/SVGAnimatedLength.h
+++ b/content/svg/content/src/SVGAnimatedLength.h
@@ -31,17 +31,18 @@ public:
   NS_IMETHOD GetBaseVal(nsIDOMSVGLength **aBaseVal)
     { *aBaseVal = BaseVal().get(); return NS_OK; }
 
   NS_IMETHOD GetAnimVal(nsIDOMSVGLength **aAnimVal)
     { *aAnimVal = AnimVal().get(); return NS_OK; }
 
   // WebIDL
   nsSVGElement* GetParentObject() { return mSVGElement; }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
   already_AddRefed<nsIDOMSVGLength> BaseVal();
   already_AddRefed<nsIDOMSVGLength> AnimVal();
 
 protected:
   nsSVGLength2* mVal; // kept alive because it belongs to content
   nsRefPtr<nsSVGElement> mSVGElement;
 };
 
--- a/content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp
+++ b/content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp
@@ -25,17 +25,17 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGAn
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGAnimatedPreserveAspectRatio)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGAnimatedPreserveAspectRatio)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 JSObject*
-DOMSVGAnimatedPreserveAspectRatio::WrapObject(JSContext* aCx, JSObject* aScope)
+DOMSVGAnimatedPreserveAspectRatio::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SVGAnimatedPreserveAspectRatioBinding::Wrap(aCx, aScope, this);
 }
 
 /* Implementation */
 
 static const char *sAlignStrings[] =
   { "none", "xMinYMin", "xMidYMin", "xMaxYMin", "xMinYMid", "xMidYMid",
--- a/content/svg/content/src/SVGAnimatedPreserveAspectRatio.h
+++ b/content/svg/content/src/SVGAnimatedPreserveAspectRatio.h
@@ -123,17 +123,18 @@ class DOMSVGAnimatedPreserveAspectRatio 
     : mVal(aVal), mSVGElement(aSVGElement)
   {
     SetIsDOMBinding();
   }
   ~DOMSVGAnimatedPreserveAspectRatio();
 
   // WebIDL
   nsSVGElement* GetParentObject() const { return mSVGElement; }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // These aren't weak refs because new objects are returned each time
   already_AddRefed<DOMSVGPreserveAspectRatio> BaseVal();
   already_AddRefed<DOMSVGPreserveAspectRatio> AnimVal();
 
 protected:
   // kept alive because it belongs to content:
   SVGAnimatedPreserveAspectRatio* mVal;
--- a/content/svg/content/src/SVGAnimatedTransformList.cpp
+++ b/content/svg/content/src/SVGAnimatedTransformList.cpp
@@ -18,17 +18,17 @@ static
   sSVGAnimatedTransformListTearoffTable;
 
 NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(SVGAnimatedTransformList, mElement)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(SVGAnimatedTransformList, AddRef)
 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(SVGAnimatedTransformList, Release)
 
 JSObject*
-SVGAnimatedTransformList::WrapObject(JSContext* aCx, JSObject* aScope)
+SVGAnimatedTransformList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SVGAnimatedTransformListBinding::Wrap(aCx, aScope, this);
 }
 
 //----------------------------------------------------------------------
 already_AddRefed<DOMSVGTransformList>
 SVGAnimatedTransformList::BaseVal()
 {
--- a/content/svg/content/src/SVGAnimatedTransformList.h
+++ b/content/svg/content/src/SVGAnimatedTransformList.h
@@ -85,17 +85,18 @@ public:
   /**
    * Returns true if our attribute is animating (in which case our animVal is
    * not simply a mirror of our baseVal).
    */
   bool IsAnimating() const;
 
   // WebIDL
   nsSVGElement* GetParentObject() const { return mElement; }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
   // These aren't weak refs because mBaseVal and mAnimVal are weak
   already_AddRefed<DOMSVGTransformList> BaseVal();
   already_AddRefed<DOMSVGTransformList> AnimVal();
 
 private:
 
   /**
    * Only our static GetDOMWrapper() factory method may create objects of our
--- a/content/svg/content/src/SVGIRect.h
+++ b/content/svg/content/src/SVGIRect.h
@@ -14,17 +14,17 @@
 #include "mozilla/ErrorResult.h"
 
 namespace mozilla {
 namespace dom {
 
 class SVGIRect : public nsIDOMSVGRect
 {
 public:
-  JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
   {
     return SVGRectBinding::Wrap(aCx, aScope, this);
   }
 
   virtual float X() const = 0;
 
   NS_IMETHOD GetX(float *aX) MOZ_OVERRIDE MOZ_FINAL
   {
--- a/content/svg/content/src/SVGMatrix.cpp
+++ b/content/svg/content/src/SVGMatrix.cpp
@@ -22,17 +22,17 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(S
 
 SVGTransform*
 SVGMatrix::GetParentObject() const
 {
   return mTransform;
 }
 
 JSObject*
-SVGMatrix::WrapObject(JSContext* aCx, JSObject* aScope)
+SVGMatrix::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SVGMatrixBinding::Wrap(aCx, aScope, this);
 }
 
 void
 SVGMatrix::SetA(float aA, ErrorResult& rv)
 {
   if (IsAnimVal()) {
--- a/content/svg/content/src/SVGMatrix.h
+++ b/content/svg/content/src/SVGMatrix.h
@@ -76,17 +76,18 @@ public:
   }
 
   const gfxMatrix& Matrix() const {
     return mTransform ? mTransform->Matrixgfx() : mMatrix;
   }
 
   // WebIDL
   SVGTransform* GetParentObject() const;
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   float A() const { return static_cast<float>(Matrix().xx); }
   void SetA(float aA, ErrorResult& rv);
   float B() const { return static_cast<float>(Matrix().yx); }
   void SetB(float aB, ErrorResult& rv);
   float C() const { return static_cast<float>(Matrix().xy); }
   void SetC(float aC, ErrorResult& rv);
   float D() const { return static_cast<float>(Matrix().yy); }
--- a/content/svg/content/src/SVGPreserveAspectRatio.cpp
+++ b/content/svg/content/src/SVGPreserveAspectRatio.cpp
@@ -25,17 +25,17 @@ bool
 SVGPreserveAspectRatio::operator==(const SVGPreserveAspectRatio& aOther) const
 {
   return mAlign == aOther.mAlign &&
     mMeetOrSlice == aOther.mMeetOrSlice &&
     mDefer == aOther.mDefer;
 }
 
 JSObject*
-DOMSVGPreserveAspectRatio::WrapObject(JSContext* aCx, JSObject* aScope)
+DOMSVGPreserveAspectRatio::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return mozilla::dom::SVGPreserveAspectRatioBinding::Wrap(aCx, aScope, this);
 }
 
 uint16_t
 DOMSVGPreserveAspectRatio::Align()
 {
   if (mIsBaseValue) {
--- a/content/svg/content/src/SVGPreserveAspectRatio.h
+++ b/content/svg/content/src/SVGPreserveAspectRatio.h
@@ -121,17 +121,18 @@ public:
     : mVal(aVal), mSVGElement(aSVGElement), mIsBaseValue(aIsBaseValue)
   {
     SetIsDOMBinding();
   }
   ~DOMSVGPreserveAspectRatio();
 
   // WebIDL
   nsSVGElement* GetParentObject() const { return mSVGElement; }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   uint16_t Align();
   void SetAlign(uint16_t aAlign, ErrorResult& rv);
   uint16_t MeetOrSlice();
   void SetMeetOrSlice(uint16_t aMeetOrSlice, ErrorResult& rv);
 
 protected:
   SVGAnimatedPreserveAspectRatio* mVal; // kept alive because it belongs to mSVGElement
--- a/content/svg/content/src/SVGTransform.cpp
+++ b/content/svg/content/src/SVGTransform.cpp
@@ -44,17 +44,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(SVGTransform)
 NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(SVGTransform, AddRef)
 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(SVGTransform, Release)
 
 JSObject*
-SVGTransform::WrapObject(JSContext* aCx, JSObject* aScope)
+SVGTransform::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SVGTransformBinding::Wrap(aCx, aScope, this);
 }
 
 //----------------------------------------------------------------------
 // Ctors:
 
 SVGTransform::SVGTransform(DOMSVGTransformList *aList,
--- a/content/svg/content/src/SVGTransform.h
+++ b/content/svg/content/src/SVGTransform.h
@@ -113,17 +113,18 @@ public:
   void RemovingFromList();
 
   nsSVGTransform ToSVGTransform() const {
     return Transform();
   }
 
   // WebIDL
   DOMSVGTransformList* GetParentObject() const { return mList; }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
   uint16_t Type() const;
   dom::SVGMatrix* Matrix();
   float Angle() const;
   void SetMatrix(dom::SVGMatrix& matrix, ErrorResult& rv);
   void SetTranslate(float tx, float ty, ErrorResult& rv);
   void SetScale(float sx, float sy, ErrorResult& rv);
   void SetRotate(float angle, float cx, float cy, ErrorResult& rv);
   void SetSkewX(float angle, ErrorResult& rv);
--- a/content/svg/content/src/nsISVGPoint.h
+++ b/content/svg/content/src/nsISVGPoint.h
@@ -135,17 +135,18 @@ public:
   }
 
   // WebIDL
   virtual float X() = 0;
   virtual void SetX(float aX, ErrorResult& rv) = 0;
   virtual float Y() = 0;
   virtual void SetY(float aY, ErrorResult& rv) = 0;
   virtual already_AddRefed<nsISVGPoint> MatrixTransform(dom::SVGMatrix& matrix) = 0;
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE
     { return dom::SVGPointBinding::Wrap(cx, scope, this); }
 
   virtual nsISupports* GetParentObject() = 0;
 
 protected:
 #ifdef DEBUG
   bool IndexIsValid();
 #endif
--- a/content/xbl/src/nsBindingManager.cpp
+++ b/content/xbl/src/nsBindingManager.cpp
@@ -74,17 +74,18 @@ public:
   }
   virtual nsIContent* Item(uint32_t aIndex);
 
   int32_t GetInsertionPointCount() { return mElements->Length(); }
 
   nsXBLInsertionPoint* GetInsertionPointAt(int32_t i) { return static_cast<nsXBLInsertionPoint*>(mElements->ElementAt(i)); }
   void RemoveInsertionPointAt(int32_t i) { mElements->RemoveElementAt(i); }
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE
   {
     return mozilla::dom::NodeListBinding::Wrap(cx, scope, this);
   }
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ANONYMOUS_CONTENT_LIST_IID)
 private:
   nsCOMPtr<nsIContent> mContent;
   nsInsertionPointList* mElements;
--- a/content/xslt/src/xpath/nsXPathEvaluator.cpp
+++ b/content/xslt/src/xpath/nsXPathEvaluator.cpp
@@ -209,17 +209,17 @@ nsXPathEvaluator::CreateExpression(const
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
     NS_ADDREF(*aResult);
     return NS_OK;
 }
 
 JSObject*
-nsXPathEvaluator::WrapObject(JSContext* aCx, JSObject* aScope)
+nsXPathEvaluator::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
     return dom::XPathEvaluatorBinding::Wrap(aCx, aScope, this);
 }
 
 /* static */
 already_AddRefed<nsXPathEvaluator>
 nsXPathEvaluator::Constructor(const GlobalObject& aGlobal, ErrorResult& rv)
 {
--- a/content/xslt/src/xpath/nsXPathEvaluator.h
+++ b/content/xslt/src/xpath/nsXPathEvaluator.h
@@ -46,17 +46,17 @@ public:
     NS_IMETHOD CreateExpression(const nsAString &aExpression, 
                                 nsIDOMXPathNSResolver *aResolver,
                                 nsTArray<nsString> *aNamespaceURIs,
                                 nsTArray<nsCString> *aContractIDs,
                                 nsCOMArray<nsISupports> *aState,
                                 nsIDOMXPathExpression **aResult);
 
     // WebIDL API
-    JSObject* WrapObject(JSContext* aCx, JSObject* aScope);
+    JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope);
     static already_AddRefed<nsXPathEvaluator>
         Constructor(const mozilla::dom::GlobalObject& aGlobal,
                     mozilla::ErrorResult& rv);
     already_AddRefed<nsIDOMXPathExpression>
         CreateExpression(const nsAString& aExpression,
                          nsIDOMXPathNSResolver* aResolver,
                          mozilla::ErrorResult& rv);
     already_AddRefed<nsIDOMXPathNSResolver>
--- a/dom/activities/src/Activity.cpp
+++ b/dom/activities/src/Activity.cpp
@@ -21,17 +21,17 @@ NS_IMPL_RELEASE_INHERITED(Activity, DOMR
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED_1(Activity, DOMRequest,
                                      mProxy)
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(Activity, DOMRequest)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 /* virtual */ JSObject*
-Activity::WrapObject(JSContext* aCx, JSObject* aScope)
+Activity::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return MozActivityBinding::Wrap(aCx, aScope, this);
 }
 
 nsresult
 Activity::Initialize(nsISupports* aOwner,
                      nsIDOMMozActivityOptions* aOptions)
 {
--- a/dom/activities/src/Activity.h
+++ b/dom/activities/src/Activity.h
@@ -18,18 +18,18 @@ namespace mozilla {
 namespace dom {
 
 class Activity : public DOMRequest
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(Activity, DOMRequest)
 
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   static bool PrefEnabled()
   {
 #ifdef MOZ_SYS_MSG
     return true;
 #else
     return false;
 #endif
--- a/dom/base/DOMCursor.cpp
+++ b/dom/base/DOMCursor.cpp
@@ -84,15 +84,15 @@ DOMCursor::Continue(ErrorResult& aRv)
     return;
   }
 
   Reset();
   mCallback->HandleContinue();
 }
 
 /* virtual */ JSObject*
-DOMCursor::WrapObject(JSContext* aCx, JSObject* aScope)
+DOMCursor::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return DOMCursorBinding::Wrap(aCx, aScope, this);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/base/DOMCursor.h
+++ b/dom/base/DOMCursor.h
@@ -22,18 +22,18 @@ class DOMCursor : public DOMRequest
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMDOMCURSOR
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DOMCursor,
                                                          DOMRequest)
 
   DOMCursor(nsIDOMWindow* aWindow, nsICursorContinueCallback *aCallback);
 
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   bool Done() const
   {
     return mFinished;
   }
   virtual void Continue(ErrorResult& aRv);
 
   void Reset();
--- a/dom/base/DOMRequest.cpp
+++ b/dom/base/DOMRequest.cpp
@@ -69,17 +69,17 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DOMRequest)
   NS_INTERFACE_MAP_ENTRY(nsIDOMDOMRequest)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
 
 NS_IMPL_ADDREF_INHERITED(DOMRequest, nsDOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(DOMRequest, nsDOMEventTargetHelper)
 
 /* virtual */ JSObject*
-DOMRequest::WrapObject(JSContext* aCx, JSObject* aScope)
+DOMRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return DOMRequestBinding::Wrap(aCx, aScope, this);
 }
 
 NS_IMPL_EVENT_HANDLER(DOMRequest, success)
 NS_IMPL_EVENT_HANDLER(DOMRequest, error)
 
 NS_IMETHODIMP
--- a/dom/base/DOMRequest.h
+++ b/dom/base/DOMRequest.h
@@ -36,18 +36,18 @@ public:
                                                          nsDOMEventTargetHelper)
 
   // WrapperCache
   nsPIDOMWindow* GetParentObject() const
   {
     return GetOwner();
   }
 
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // WebIDL Interface
   DOMRequestReadyState ReadyState() const
   {
     return mDone ? DOMRequestReadyStateValues::Done
                  : DOMRequestReadyStateValues::Pending;
   }
 
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -285,17 +285,18 @@ public:
   nsPIDOMWindow* GetPrivateParent();
   // callback for close event
   void ReallyCloseWindow();
 
   // nsISupports
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   // nsWrapperCache
-  JSObject *WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE
+  virtual JSObject *WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE
   {
     NS_ASSERTION(IsOuterWindow(),
                  "Inner window supports nsWrapperCache, fix WrapObject!");
     return EnsureInnerWindow() ? GetWrapper() : nullptr;
   }
 
   // nsIGlobalJSObjectHolder
   virtual JSObject *GetGlobalJSObject();
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -3396,17 +3396,17 @@ NS_DOMReadStructuredClone(JSContext* cx,
       return nullptr;
     }
     MOZ_ASSERT(dataArray.isObject());
 
     // Construct the ImageData.
     nsRefPtr<ImageData> imageData = new ImageData(width, height,
                                                   dataArray.toObject());
     // Wrap it in a JS::Value.
-    JSObject* global = JS_GetGlobalForScopeChain(cx);
+    JS::Rooted<JSObject*> global(cx, JS_GetGlobalForScopeChain(cx));
     if (!global) {
       return nullptr;
     }
     return imageData->WrapObject(cx, global);
   }
 
   // Don't know what this is. Bail.
   xpc::Throw(cx, NS_ERROR_DOM_DATA_CLONE_ERR);
--- a/dom/base/nsPerformance.cpp
+++ b/dom/base/nsPerformance.cpp
@@ -119,17 +119,17 @@ nsPerformanceTiming::ResponseEnd() const
   mChannel->GetCacheReadEnd(&cacheStamp);
   if (stamp.IsNull() || (!cacheStamp.IsNull() && cacheStamp < stamp)) {
     stamp = cacheStamp;
   }
   return GetDOMTiming()->TimeStampToDOMOrFetchStart(stamp);
 }
 
 JSObject*
-nsPerformanceTiming::WrapObject(JSContext *cx, JSObject *scope)
+nsPerformanceTiming::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return dom::PerformanceTimingBinding::Wrap(cx, scope, this);
 }
 
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsPerformanceNavigation, mPerformance)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsPerformanceNavigation, AddRef)
@@ -142,17 +142,17 @@ nsPerformanceNavigation::nsPerformanceNa
   SetIsDOMBinding();
 }
 
 nsPerformanceNavigation::~nsPerformanceNavigation()
 {
 }
 
 JSObject*
-nsPerformanceNavigation::WrapObject(JSContext *cx, JSObject *scope)
+nsPerformanceNavigation::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return dom::PerformanceNavigationBinding::Wrap(cx, scope, this);
 }
 
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_3(nsPerformance,
                                         mWindow, mTiming,
                                         mNavigation)
@@ -201,13 +201,13 @@ nsPerformance::Navigation()
 
 DOMHighResTimeStamp
 nsPerformance::Now()
 {
   return GetDOMTiming()->TimeStampToDOMHighRes(mozilla::TimeStamp::Now());
 }
 
 JSObject*
-nsPerformance::WrapObject(JSContext *cx, JSObject *scope)
+nsPerformance::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return dom::PerformanceBinding::Wrap(cx, scope, this);
 }
 
--- a/dom/base/nsPerformance.h
+++ b/dom/base/nsPerformance.h
@@ -30,17 +30,18 @@ public:
 
   nsDOMNavigationTiming* GetDOMTiming() const;
 
   nsPerformance* GetParentObject() const
   {
     return mPerformance;
   }
 
-  JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   // PerformanceNavigation WebIDL methods
   DOMTimeMilliSec NavigationStart() const {
     return GetDOMTiming()->GetNavigationStart();
   }
   DOMTimeMilliSec UnloadEventStart() {
     return GetDOMTiming()->GetUnloadEventStart();
   }
@@ -101,17 +102,18 @@ public:
 
   nsDOMNavigationTiming* GetDOMTiming() const;
 
   nsPerformance* GetParentObject() const
   {
     return mPerformance;
   }
 
-  JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   // PerformanceNavigation WebIDL methods
   uint16_t Type() const {
     return GetDOMTiming()->GetType();
   }
   uint16_t RedirectCount() const {
     return GetDOMTiming()->GetRedirectCount();
   }
@@ -143,17 +145,18 @@ public:
     return mChannel;
   }
 
   nsIDOMWindow* GetParentObject() const
   {
     return mWindow.get();
   }
 
-  JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
   // Performance WebIDL methods
   DOMHighResTimeStamp Now();
   nsPerformanceTiming* Timing();
   nsPerformanceNavigation* Navigation();
 
 private:
   ~nsPerformance();
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -404,17 +404,17 @@ NS_IMETHODIMP
 nsScreen::SlowMozUnlockOrientation()
 {
   MozUnlockOrientation();
   return NS_OK;
 }
 
 /* virtual */
 JSObject*
-nsScreen::WrapObject(JSContext* aCx, JSObject* aScope)
+nsScreen::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return ScreenBinding::Wrap(aCx, aScope, this);
 }
 
 NS_IMPL_ISUPPORTS1(nsScreen::FullScreenEventListener, nsIDOMEventListener)
 
 NS_IMETHODIMP
 nsScreen::FullScreenEventListener::HandleEvent(nsIDOMEvent* aEvent)
--- a/dom/base/nsScreen.h
+++ b/dom/base/nsScreen.h
@@ -109,17 +109,18 @@ public:
 
   bool MozLockOrientation(const nsAString& aOrientation, ErrorResult& aRv);
   bool MozLockOrientation(const mozilla::dom::Sequence<nsString>& aOrientations, ErrorResult& aRv);
   void MozUnlockOrientation();
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsScreen,
                                            nsDOMEventTargetHelper)
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   void Notify(const mozilla::hal::ScreenConfiguration& aConfiguration);
 
 protected:
   nsDeviceContext* GetDeviceContext();
   nsresult GetRect(nsRect& aRect);
   nsresult GetAvailRect(nsRect& aRect);
 
--- a/dom/base/nsWrapperCache.h
+++ b/dom/base/nsWrapperCache.h
@@ -3,16 +3,17 @@
  * 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/. */
 
 #ifndef nsWrapperCache_h___
 #define nsWrapperCache_h___
 
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Assertions.h"
+#include "js/RootingAPI.h"
 
 class JSObject;
 struct JSContext;
 class XPCWrappedNativeScope;
 
 namespace mozilla {
 namespace dom {
 namespace workers {
@@ -144,17 +145,17 @@ public:
   {
     return (mWrapperPtrBits & WRAPPER_HAS_SOW) != 0;
   }
 
   /**
    * Wrap the object corresponding to this wrapper cache. If non-null is
    * returned, the object has already been stored in the wrapper cache.
    */
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope)
+  virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
   {
     MOZ_ASSERT(!IsDOMBinding(), "Someone forgot to override WrapObject");
     return nullptr;
   }
 
   /**
    * Returns true if the object has a non-gray wrapper.
    */
--- a/dom/battery/BatteryManager.cpp
+++ b/dom/battery/BatteryManager.cpp
@@ -49,17 +49,17 @@ BatteryManager::Init(nsPIDOMWindow *aWin
 
 void
 BatteryManager::Shutdown()
 {
   hal::UnregisterBatteryObserver(this);
 }
 
 JSObject*
-BatteryManager::WrapObject(JSContext* aCx, JSObject* aScope)
+BatteryManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return BatteryManagerBinding::Wrap(aCx, aScope, this);
 }
 
 double
 BatteryManager::DischargingTime() const
 {
   if (mCharging || mRemainingTime == kUnknownRemainingTime) {
--- a/dom/battery/BatteryManager.h
+++ b/dom/battery/BatteryManager.h
@@ -46,17 +46,18 @@ public:
    * WebIDL Interface
    */
 
   nsPIDOMWindow* GetParentObject() const
   {
      return GetOwner();
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   bool Charging() const
   {
     return mCharging;
   }
 
   double ChargingTime() const;
 
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -393,17 +393,18 @@ HAS_MEMBER(WrapObject)
 // HasWrapObject<T>::Value will be true if T has a WrapObject member but it's
 // not nsWrapperCache::WrapObject.
 template<typename T>
 struct HasWrapObject
 {
 private:
   typedef char yes[1];
   typedef char no[2];
-  typedef JSObject* (nsWrapperCache::*WrapObject)(JSContext*, JSObject*);
+  typedef JSObject* (nsWrapperCache::*WrapObject)(JSContext*,
+                                                  JS::Handle<JSObject*>);
   template<typename U, U> struct SFINAE;
   template <typename V> static no& Check(SFINAE<WrapObject, &V::WrapObject>*);
   template <typename V> static yes& Check(...);
 
 public:
   static bool const Value = HasWrapObjectMember<T>::Value &&
                             sizeof(Check<T>(nullptr)) == sizeof(yes);
 };
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -8174,17 +8174,17 @@ class CGBindingImplClass(CGClass):
                     descriptor, FakeMember(),
                     "GetSupportedNames",
                     (IDLSequenceType(None,
                                      BuiltinTypes[IDLBuiltinType.Types.domstring]),
                      []),
                     { "infallible": True }))
 
         wrapArgs = [Argument('JSContext*', 'aCx'),
-                    Argument('JSObject*', 'aScope')]
+                    Argument('JS::Handle<JSObject*>', 'aScope')]
         self.methodDecls.insert(0,
                                 ClassMethod("WrapObject", "JSObject*",
                                             wrapArgs, virtual=descriptor.wrapperCache,
                                             breakAfterReturnDecl=" ",
                                             override=descriptor.wrapperCache,
                                             body=self.getWrapObjectBody()))
         self.methodDecls.insert(0,
                                 ClassMethod("GetParentObject",
@@ -8248,17 +8248,17 @@ NS_INTERFACE_MAP_END
   SetIsDOMBinding();
 }
 
 ${nativeType}::~${nativeType}()
 {
 }
 
 JSObject*
-${nativeType}::WrapObject(JSContext* aCx, JSObject* aScope)
+${nativeType}::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return ${ifaceName}Binding::Wrap(aCx, aScope, this);
 }
 
 """
         return string.Template(classImpl).substitute(
             { "ifaceName": self.descriptor.name,
               "nativeType": self.descriptor.nativeType.split('::')[-1] }
--- a/dom/bindings/test/TestBindingHeader.h
+++ b/dom/bindings/test/TestBindingHeader.h
@@ -77,17 +77,17 @@ public:
   NS_DECL_ISUPPORTS
 };
 
 class TestNonWrapperCacheInterface : public nsISupports
 {
 public:
   NS_DECL_ISUPPORTS
 
-  virtual JSObject* WrapObject(JSContext* cx, JSObject* scope);
+  virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> scope);
 };
 
 class OnlyForUseInConstructor : public nsISupports,
                                 public nsWrapperCache
 {
 public:
   NS_DECL_ISUPPORTS
   // We need a GetParentObject to make binding codegen happy
--- a/dom/encoding/TextDecoder.h
+++ b/dom/encoding/TextDecoder.h
@@ -39,18 +39,18 @@ public:
     MOZ_ASSERT(aGlobal);
     SetIsDOMBinding();
   }
 
   virtual
   ~TextDecoder()
   {}
 
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return TextDecoderBinding::Wrap(aCx, aScope, this);
   }
 
   nsISupports*
   GetParentObject()
   {
     return mGlobal;
--- a/dom/encoding/TextEncoder.h
+++ b/dom/encoding/TextEncoder.h
@@ -38,18 +38,18 @@ public:
     MOZ_ASSERT(aGlobal);
     SetIsDOMBinding();
   }
 
   virtual
   ~TextEncoder()
   {}
 
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return TextEncoderBinding::Wrap(aCx, aScope, this);
   }
 
   nsISupports*
   GetParentObject()
   {
     return mGlobal;
--- a/dom/file/ArchiveReader.cpp
+++ b/dom/file/ArchiveReader.cpp
@@ -57,17 +57,17 @@ ArchiveReader::ArchiveReader(nsIDOMBlob*
 }
 
 ArchiveReader::~ArchiveReader()
 {
   nsLayoutStatics::Release();
 }
 
 /* virtual */ JSObject*
-ArchiveReader::WrapObject(JSContext* aCx, JSObject* aScope)
+ArchiveReader::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return ArchiveReaderBinding::Wrap(aCx, aScope, this);
 }
 
 /* static */ bool
 ArchiveReader::PrefEnabled()
 {
   return Preferences::GetBool("dom.archivereader.enabled", true);
--- a/dom/file/ArchiveReader.h
+++ b/dom/file/ArchiveReader.h
@@ -43,18 +43,18 @@ public:
 
   ArchiveReader(nsIDOMBlob* aBlob, nsPIDOMWindow* aWindow,
                 const nsString& aEncoding);
 
   nsIDOMWindow* GetParentObject() const
   {
     return mWindow;
   }
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   already_AddRefed<ArchiveRequest> GetFilenames();
   already_AddRefed<ArchiveRequest> GetFile(const nsAString& filename);
   already_AddRefed<ArchiveRequest> GetFiles();
 
   nsresult GetInputStream(nsIInputStream** aInputStream);
   nsresult GetSize(uint64_t* aSize);
 
--- a/dom/file/ArchiveRequest.cpp
+++ b/dom/file/ArchiveRequest.cpp
@@ -72,17 +72,17 @@ nsresult
 ArchiveRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = true;
   aVisitor.mParentTarget = nullptr;
   return NS_OK;
 }
 
 /* virtual */ JSObject*
-ArchiveRequest::WrapObject(JSContext* aCx, JSObject* aScope)
+ArchiveRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return ArchiveRequestBinding::Wrap(aCx, aScope, this);
 }
 
 ArchiveReader*
 ArchiveRequest::Reader() const
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
--- a/dom/file/ArchiveRequest.h
+++ b/dom/file/ArchiveRequest.h
@@ -22,18 +22,18 @@ BEGIN_FILE_NAMESPACE
 class ArchiveRequest : public mozilla::dom::DOMRequest
 {
 public:
   static bool PrefEnabled()
   {
     return ArchiveReader::PrefEnabled();
   }
 
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   ArchiveReader* Reader() const;
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveRequest, DOMRequest)
 
   ArchiveRequest(nsIDOMWindow* aWindow,
--- a/dom/file/DOMFileRequest.cpp
+++ b/dom/file/DOMFileRequest.cpp
@@ -12,17 +12,17 @@
 USING_FILE_NAMESPACE
 
 DOMFileRequest::DOMFileRequest(nsIDOMWindow* aWindow)
   : FileRequest(aWindow)
 {
 }
 
 /* virtual */ JSObject*
-DOMFileRequest::WrapObject(JSContext* aCx, JSObject* aScope)
+DOMFileRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return FileRequestBinding::Wrap(aCx, aScope, this);
 }
 
 nsIDOMLockedFile*
 DOMFileRequest::GetLockedFile() const
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
--- a/dom/file/DOMFileRequest.h
+++ b/dom/file/DOMFileRequest.h
@@ -13,18 +13,18 @@ class nsIDOMLockedFile;
 
 BEGIN_FILE_NAMESPACE
 
 class DOMFileRequest : public FileRequest
 {
 public:
   DOMFileRequest(nsIDOMWindow* aWindow);
 
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   nsIDOMLockedFile* GetLockedFile() const;
   IMPL_EVENT_HANDLER(progress)
 };
 
 END_FILE_NAMESPACE
 
 #endif // mozilla_dom_file_DOMFileRequest_h
--- a/dom/file/FileHandle.cpp
+++ b/dom/file/FileHandle.cpp
@@ -196,12 +196,12 @@ GetFileHelper::GetSuccessResult(JSContex
                                &NS_GET_IID(nsIDOMFile), aVal);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
 
   return NS_OK;
 }
 
 /* virtual */
 JSObject*
-FileHandle::WrapObject(JSContext* aCx, JSObject* aScope)
+FileHandle::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return FileHandleBinding::Wrap(aCx, aScope, this);
 }
--- a/dom/file/FileHandle.h
+++ b/dom/file/FileHandle.h
@@ -51,17 +51,18 @@ class FileHandle : public nsDOMEventTarg
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMFILEHANDLE
 
   nsPIDOMWindow* GetParentObject() const
   {
     return GetOwner();
   }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   void GetName(nsString& aName) const
   {
     aName = mName;
   }
   void GetType(nsString& aType) const
   {
     aType = mType;
--- a/dom/indexedDB/IDBEvents.h
+++ b/dom/indexedDB/IDBEvents.h
@@ -46,17 +46,18 @@ CreateGenericEvent(mozilla::dom::EventTa
 class IDBVersionChangeEvent : public nsDOMEvent,
                               public nsIIDBVersionChangeEvent
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_TO_NSDOMEVENT
   NS_DECL_NSIIDBVERSIONCHANGEEVENT
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
     return mozilla::dom::IDBVersionChangeEventBinding::Wrap(aCx, aScope, this);
   }
 
   uint64_t OldVersion()
   {
     return mOldVersion;
   }
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -612,17 +612,17 @@ IDBFactory::OpenInternal(const nsAString
   }
 #endif
 
   request.forget(_retval);
   return NS_OK;
 }
 
 JSObject*
-IDBFactory::WrapObject(JSContext* aCx, JSObject* aScope)
+IDBFactory::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return IDBFactoryBinding::Wrap(aCx, aScope, this);
 }
 
 int16_t
 IDBFactory::Cmp(JSContext* aCx, JS::Value aFirst, JS::Value aSecond,
                 ErrorResult& aRv)
 {
--- a/dom/indexedDB/IDBFactory.h
+++ b/dom/indexedDB/IDBFactory.h
@@ -134,18 +134,18 @@ public:
   }
 
   // WrapperCache
   nsPIDOMWindow* GetParentObject() const
   {
     return mWindow;
   }
 
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // WebIDL
   already_AddRefed<nsIIDBOpenDBRequest>
   Open(JSContext* aCx, const NonNull<nsAString>& aName,
        const Optional<uint64_t>& aVersion, ErrorResult& aRv)
   {
     return Open(aCx, nullptr, aName, aVersion, false, aRv);
   }
--- a/dom/src/geolocation/nsGeoPosition.cpp
+++ b/dom/src/geolocation/nsGeoPosition.cpp
@@ -173,17 +173,17 @@ Position::~Position()
 
 nsISupports*
 Position::GetParentObject() const
 {
   return mParent;
 }
 
 JSObject*
-Position::WrapObject(JSContext* aCx, JSObject* aScope)
+Position::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return PositionBinding::Wrap(aCx, aScope, this);
 }
 
 Coordinates*
 Position::Coords()
 {
   if (!mCoordinates) {
@@ -227,17 +227,17 @@ Coordinates::~Coordinates()
 
 Position*
 Coordinates::GetParentObject() const
 {
   return mPosition;
 }
 
 JSObject*
-Coordinates::WrapObject(JSContext* aCx, JSObject* aScope)
+Coordinates::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return CoordinatesBinding::Wrap(aCx, aScope, this);
 }
 
 #define GENERATE_COORDS_WRAPPED_GETTER(name) \
 double                                       \
 Coordinates::name() const                    \
 {                                            \
--- a/dom/src/geolocation/nsGeoPosition.h
+++ b/dom/src/geolocation/nsGeoPosition.h
@@ -86,17 +86,18 @@ public:
 
 public:
   Position(nsISupports* aParent, nsIDOMGeoPosition* aGeoPosition);
 
   ~Position();
 
   nsISupports* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   Coordinates* Coords();
 
   uint64_t Timestamp() const;
 
   nsIDOMGeoPosition* GetWrappedGeoPosition() { return mGeoPosition; }
 
 private:
@@ -114,17 +115,18 @@ public:
 
 public:
   Coordinates(Position* aPosition, nsIDOMGeoPositionCoords* aCoords);
 
   ~Coordinates();
 
   Position* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   double Latitude() const;
 
   double Longitude() const;
 
   Nullable<double> GetAltitude() const;
 
   double Accuracy() const;
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -264,17 +264,17 @@ PositionError::GetCode(int16_t *aCode)
 
 Geolocation*
 PositionError::GetParentObject() const
 {
   return mParent;
 }
 
 JSObject*
-PositionError::WrapObject(JSContext* aCx, JSObject* aScope)
+PositionError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return PositionErrorBinding::Wrap(aCx, aScope, this);
 }
 
 void
 PositionError::NotifyCallback(const GeoPositionErrorCallback& aCallback)
 {
   // Ensure that the proper context is on the stack (bug 452762)
@@ -1596,12 +1596,12 @@ Geolocation::RegisterRequestWithPrompt(n
   }
 
   nsCOMPtr<nsIRunnable> ev  = new RequestPromptEvent(request);
   NS_DispatchToMainThread(ev);
   return true;
 }
 
 JSObject*
-Geolocation::WrapObject(JSContext *aCtx, JSObject *aScope)
+Geolocation::WrapObject(JSContext *aCtx, JS::Handle<JSObject*> aScope)
 {
   return mozilla::dom::GeolocationBinding::Wrap(aCtx, aScope, this);
 }
--- a/dom/src/geolocation/nsGeolocation.h
+++ b/dom/src/geolocation/nsGeolocation.h
@@ -190,17 +190,18 @@ public:
 
   NS_DECL_NSIDOMGEOGEOLOCATION
 
   Geolocation();
 
   nsresult Init(nsIDOMWindow* contentDom=nullptr);
 
   nsIDOMWindow* GetParentObject() const;
-  virtual JSObject* WrapObject(JSContext *aCtx, JSObject *aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *aCtx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   int32_t WatchPosition(PositionCallback& aCallback, PositionErrorCallback* aErrorCallback, const PositionOptions& aOptions, ErrorResult& aRv);
   void GetCurrentPosition(PositionCallback& aCallback, PositionErrorCallback* aErrorCallback, const PositionOptions& aOptions, ErrorResult& aRv);
 
   // Called by the geolocation device to notify that a location has changed.
   void Update(nsIDOMGeoPosition* aPosition, bool aIsBetter);
 
   void SetCachedPosition(Position* aPosition);
@@ -288,17 +289,18 @@ public:
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PositionError)
 
   NS_DECL_NSIDOMGEOPOSITIONERROR
 
   PositionError(Geolocation* aParent, int16_t aCode);
 
   Geolocation* GetParentObject() const;
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   int16_t Code() const {
     return mCode;
   }
 
   void GetMessage(nsString& aRetVal) const {
     aRetVal.Truncate();
   }
--- a/dom/src/notification/DesktopNotification.cpp
+++ b/dom/src/notification/DesktopNotification.cpp
@@ -195,17 +195,17 @@ DesktopNotification::Show(ErrorResult& a
   if (!mAllow) {
     return;
   }
 
   aRv = PostDesktopNotification();
 }
 
 JSObject*
-DesktopNotification::WrapObject(JSContext* aCx, JSObject* aScope)
+DesktopNotification::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return DesktopNotificationBinding::Wrap(aCx, aScope, this);
 }
 
 /* ------------------------------------------------------------------------ */
 /* DesktopNotificationCenter                                                */
 /* ------------------------------------------------------------------------ */
 
@@ -230,17 +230,17 @@ DesktopNotificationCenter::CreateNotific
                             aIconURL,
                             mOwner,
                             mPrincipal);
   notification->Init();
   return notification.forget();
 }
 
 JSObject*
-DesktopNotificationCenter::WrapObject(JSContext* aCx, JSObject* aScope)
+DesktopNotificationCenter::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return DesktopNotificationCenterBinding::Wrap(aCx, aScope, this);
 }
 
 /* ------------------------------------------------------------------------ */
 /* DesktopNotificationRequest                                               */
 /* ------------------------------------------------------------------------ */
 
--- a/dom/src/notification/DesktopNotification.h
+++ b/dom/src/notification/DesktopNotification.h
@@ -65,17 +65,18 @@ public:
     mOwner = nullptr;
   }
 
   nsPIDOMWindow* GetParentObject() const
   {
     return mOwner;
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   already_AddRefed<DesktopNotification>
   CreateNotification(const nsAString& title,
                      const nsAString& description,
                      const nsAString& iconURL);
 
 private:
   nsCOMPtr<nsPIDOMWindow> mOwner;
@@ -116,17 +117,18 @@ public:
 
   // WebIDL
 
   nsPIDOMWindow* GetParentObject() const
   {
     return GetOwner();
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   void Show(ErrorResult& aRv);
 
   IMPL_EVENT_HANDLER(click)
   IMPL_EVENT_HANDLER(close)
 
 protected:
 
--- a/dom/src/notification/Notification.cpp
+++ b/dom/src/notification/Notification.cpp
@@ -448,17 +448,17 @@ Notification::GetPermissionInternal(nsIS
 
 bool
 Notification::PrefEnabled()
 {
   return Preferences::GetBool("dom.webnotifications.enabled", false);
 }
 
 JSObject*
-Notification::WrapObject(JSContext* aCx, JSObject* aScope)
+Notification::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return mozilla::dom::NotificationBinding::Wrap(aCx, aScope, this);
 }
 
 void
 Notification::Close()
 {
   // Queue a task to close the notification.
--- a/dom/src/notification/Notification.h
+++ b/dom/src/notification/Notification.h
@@ -46,17 +46,18 @@ public:
 
   static bool PrefEnabled();
 
   nsPIDOMWindow* GetParentObject()
   {
     return GetOwner();
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 protected:
   nsresult ShowInternal();
   nsresult CloseInternal();
 
   static NotificationPermission GetPermissionInternal(nsISupports* aGlobal,
                                                       ErrorResult& rv);
 
   static const nsString DirectionToString(NotificationDirection aDirection)
--- a/dom/system/gonk/AudioChannelManager.cpp
+++ b/dom/system/gonk/AudioChannelManager.cpp
@@ -28,17 +28,17 @@ AudioChannelManager::~AudioChannelManage
 void
 AudioChannelManager::Init(nsPIDOMWindow* aWindow)
 {
   BindToOwner(aWindow->IsOuterWindow() ?
     aWindow->GetCurrentInnerWindow() : aWindow);
 }
 
 JSObject*
-AudioChannelManager::WrapObject(JSContext* aCx, JSObject* aScope)
+AudioChannelManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return AudioChannelManagerBinding::Wrap(aCx, aScope, this);
 }
 
 void
 AudioChannelManager::Notify(const SwitchEvent& aEvent)
 {
   if (aEvent.status() == SWITCH_STATE_ON ||
--- a/dom/system/gonk/AudioChannelManager.h
+++ b/dom/system/gonk/AudioChannelManager.h
@@ -33,17 +33,18 @@ public:
    * WebIDL Interface
    */
 
   nsPIDOMWindow* GetParentObject() const
   {
      return GetOwner();
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   bool Headphones() const
   {
     return mState == hal::SWITCH_STATE_ON;
   }
 
   IMPL_EVENT_HANDLER(headphoneschange)
 
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -1737,17 +1737,17 @@ nsCSSFontFaceStyleDecl::SetPropertyValue
 
 nsINode*
 nsCSSFontFaceStyleDecl::GetParentObject()
 {
   return ContainingRule()->GetDocument();
 }
 
 JSObject*
-nsCSSFontFaceStyleDecl::WrapObject(JSContext *cx, JSObject *scope)
+nsCSSFontFaceStyleDecl::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return mozilla::dom::CSSStyleDeclarationBinding::Wrap(cx, scope, this);
 }
 
 // -------------------------------------------
 // nsCSSFontFaceRule
 // 
 
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -198,17 +198,18 @@ public:
   }
 
   virtual nsINode *GetParentObject() MOZ_OVERRIDE;
   virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) MOZ_OVERRIDE;
 
   nsresult GetPropertyValue(nsCSSFontDesc aFontDescID,
                             nsAString & aResult) const;
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
 protected:
   friend class nsCSSFontFaceRule;
 #define CSS_FONT_DESC(name_, method_) nsCSSValue m##method_;
 #include "nsCSSFontDescList.h"
 #undef CSS_FONT_DESC
 
   static nsCSSValue nsCSSFontFaceStyleDecl::* const Fields[];  
--- a/layout/style/nsCSSStyleSheet.cpp
+++ b/layout/style/nsCSSStyleSheet.cpp
@@ -2255,12 +2255,12 @@ nsCSSStyleSheet::ParseSheet(const nsAStr
 /* virtual */ nsIURI*
 nsCSSStyleSheet::GetOriginalURI() const
 {
   return mInner->mOriginalSheetURI;
 }
 
 /* virtual */
 JSObject*
-nsCSSStyleSheet::WrapObject(JSContext* aCx, JSObject* aScope)
+nsCSSStyleSheet::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return CSSStyleSheetBinding::Wrap(aCx, aScope, this);
 }
--- a/layout/style/nsCSSStyleSheet.h
+++ b/layout/style/nsCSSStyleSheet.h
@@ -292,17 +292,18 @@ public:
   mozilla::dom::ParentObject GetParentObject() const {
     if (mOwningNode) {
       return mozilla::dom::ParentObject(mOwningNode);
     }
 
     return mozilla::dom::ParentObject(static_cast<nsIStyleSheet*>(mParent),
                                       mParent);
   }
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
 private:
   nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
                   nsCSSStyleSheet* aParentToUse,
                   mozilla::css::ImportRule* aOwnerRuleToUse,
                   nsIDocument* aDocumentToUse,
                   nsINode* aOwningNodeToUse);
 
--- a/layout/style/nsDOMCSSDeclaration.h
+++ b/layout/style/nsDOMCSSDeclaration.h
@@ -87,17 +87,18 @@ public:
 
 #undef CSS_PROP_SHORTHAND
 #undef CSS_PROP_LIST_EXCLUDE_INTERNAL
 #undef CSS_PROP
 #undef CSS_PROP_PUBLIC_OR_PRIVATE
 
   virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName);
 
-  virtual JSObject* WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE
+  virtual JSObject* WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE
   {
     return mozilla::dom::CSS2PropertiesBinding::Wrap(cx, scope, this);
   }
 
 protected:
   // This method can return null regardless of the value of aAllocate;
   // however, a null return should only be considered a failure
   // if aAllocate is true.
--- a/layout/style/nsDOMCSSRGBColor.cpp
+++ b/layout/style/nsDOMCSSRGBColor.cpp
@@ -28,13 +28,13 @@ nsDOMCSSRGBColor::~nsDOMCSSRGBColor(void
 }
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_4(nsDOMCSSRGBColor, mAlpha,  mBlue, mGreen, mRed)
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsDOMCSSRGBColor, AddRef)
 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsDOMCSSRGBColor, Release)
 
 JSObject*
-nsDOMCSSRGBColor::WrapObject(JSContext *aCx, JSObject *aScope)
+nsDOMCSSRGBColor::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
 {
   return dom::RGBColorBinding::Wrap(aCx, aScope, this);
 }
 
--- a/layout/style/nsDOMCSSRGBColor.h
+++ b/layout/style/nsDOMCSSRGBColor.h
@@ -49,17 +49,17 @@ public:
     return mAlpha;
   }
 
   nsISupports* GetParentObject() const
   {
     return nullptr;
   }
 
-  virtual JSObject *WrapObject(JSContext *cx, JSObject *aScope)
+  virtual JSObject *WrapObject(JSContext *cx, JS::Handle<JSObject*> aScope)
     MOZ_OVERRIDE MOZ_FINAL;
 
 private:
   nsRefPtr<nsROCSSPrimitiveValue> mRed;
   nsRefPtr<nsROCSSPrimitiveValue> mGreen;
   nsRefPtr<nsROCSSPrimitiveValue> mBlue;
   nsRefPtr<nsROCSSPrimitiveValue> mAlpha;
   bool mHasAlpha;
--- a/layout/style/nsDOMCSSRect.cpp
+++ b/layout/style/nsDOMCSSRect.cpp
@@ -37,17 +37,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSRect)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSRect)
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_4(nsDOMCSSRect, mTop, mBottom, mLeft, mRight)
  
 JSObject*
-nsDOMCSSRect::WrapObject(JSContext* cx, JSObject* scope)
+nsDOMCSSRect::WrapObject(JSContext* cx, JS::Handle<JSObject*> scope)
 {
  return dom::RectBinding::Wrap(cx, scope, this);
 }
 
 NS_IMETHODIMP
 nsDOMCSSRect::GetTop(nsIDOMCSSPrimitiveValue** aTop)
 {
   NS_ENSURE_TRUE(mTop, NS_ERROR_NOT_INITIALIZED);
--- a/layout/style/nsDOMCSSRect.h
+++ b/layout/style/nsDOMCSSRect.h
@@ -34,17 +34,17 @@ public:
 
   nsROCSSPrimitiveValue* Top() const { return mTop; }
   nsROCSSPrimitiveValue* Right() const { return mRight; }
   nsROCSSPrimitiveValue* Bottom() const { return mBottom; }
   nsROCSSPrimitiveValue* Left() const { return mLeft; }
 
   nsISupports* GetParentObject() const { return nullptr; }
 
-  virtual JSObject* WrapObject(JSContext* cx, JSObject* scope)
+  virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> scope)
     MOZ_OVERRIDE MOZ_FINAL;
 
 private:
   nsRefPtr<nsROCSSPrimitiveValue> mTop;
   nsRefPtr<nsROCSSPrimitiveValue> mRight;
   nsRefPtr<nsROCSSPrimitiveValue> mBottom;
   nsRefPtr<nsROCSSPrimitiveValue> mLeft;
 };
--- a/layout/style/nsDOMCSSValueList.cpp
+++ b/layout/style/nsDOMCSSValueList.cpp
@@ -30,17 +30,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValue)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValueList)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, CSSValue)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsDOMCSSValueList, mCSSValues)
 
 JSObject*
-nsDOMCSSValueList::WrapObject(JSContext *cx, JSObject *scope)
+nsDOMCSSValueList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return dom::CSSValueListBinding::Wrap(cx, scope, this);
 }
 
 void
 nsDOMCSSValueList::AppendCSSValue(CSSValue* aValue)
 {
   mCSSValues.AppendElement(aValue);
--- a/layout/style/nsDOMCSSValueList.h
+++ b/layout/style/nsDOMCSSValueList.h
@@ -52,17 +52,18 @@ public:
     return mCSSValues.Length();
   }
 
   nsISupports* GetParentObject()
   {
     return nullptr;
   }
 
-  virtual JSObject *WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject *WrapObject(JSContext *cx,
+			       JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
 private:
   bool                        mCommaDelimited;  // some value lists use a comma
                                                 // as the delimiter, some just use
                                                 // spaces.
 
   bool                        mReadonly;    // Are we read-only?
 
--- a/layout/style/nsROCSSPrimitiveValue.cpp
+++ b/layout/style/nsROCSSPrimitiveValue.cpp
@@ -57,17 +57,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsROCSSPrimitiveValue)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
   tmp->Reset();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 JSObject*
-nsROCSSPrimitiveValue::WrapObject(JSContext *cx, JSObject *scope)
+nsROCSSPrimitiveValue::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return dom::CSSPrimitiveValueBinding::Wrap(cx, scope, this);
 }
 
 // nsIDOMCSSValue
 
 
 NS_IMETHODIMP
--- a/layout/style/nsROCSSPrimitiveValue.h
+++ b/layout/style/nsROCSSPrimitiveValue.h
@@ -77,17 +77,18 @@ public:
   void SetTime(float aValue);
   void Reset();
 
   nsISupports* GetParentObject() const
   {
     return nullptr;
   }
 
-  virtual JSObject *WrapObject(JSContext *cx, JSObject *scope) MOZ_OVERRIDE;
+  virtual JSObject *WrapObject(JSContext *cx,
+                               JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
 
 private:
   uint16_t mType;
 
   union {
     nscoord         mAppUnits;
     float           mFloat;
     nsDOMCSSRGBColor* mColor;
--- a/layout/xul/tree/nsTreeColumns.cpp
+++ b/layout/xul/tree/nsTreeColumns.cpp
@@ -369,17 +369,17 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTreeC
 
 nsIContent*
 nsTreeColumns::GetParentObject() const
 {
   return mTree ? mTree->GetBaseElement() : nullptr;
 }
 
 /* virtual */ JSObject*
-nsTreeColumns::WrapObject(JSContext* aCx, JSObject* aScope)
+nsTreeColumns::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return dom::TreeColumnsBinding::Wrap(aCx, aScope, this);
 }
 
 nsITreeBoxObject*
 nsTreeColumns::GetTree() const
 {
   return mTree ? mTree->GetTreeBoxObject() : nullptr;
--- a/layout/xul/tree/nsTreeColumns.h
+++ b/layout/xul/tree/nsTreeColumns.h
@@ -129,17 +129,18 @@ public:
   nsTreeColumns(nsTreeBodyFrame* aTree);
   ~nsTreeColumns();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsTreeColumns)
   NS_DECL_NSITREECOLUMNS
 
   nsIContent* GetParentObject() const;
-  virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   // WebIDL
   nsITreeBoxObject* GetTree() const;
   uint32_t Count();
   uint32_t Length()
   {
     return Count();
   }