Merge inbound to m-c a=merge CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Fri, 10 Oct 2014 18:58:06 -0700
changeset 209907 f74ad36bb97b85909f7a3430288c07d3bf8b4e50
parent 209843 999ad2f1e1089d203811266bc3c9bfa92308f029 (current diff)
parent 209906 a1e44f48ddbdc4cf573bd23db01f35804e414bde (diff)
child 209908 ac36d46fb940be5b8ec35d7454f0c02613fcebc7
child 209915 4c6a3e307c609c8da86722c5199b242ccdace442
child 209938 d273b68bdcb3de2e70df0d2f6bc4aa05089a04dc
child 209948 896ed43b6b6128901455833025296f8a2ebc1d5c
push id27628
push userkwierso@gmail.com
push dateSat, 11 Oct 2014 02:00:16 +0000
treeherdermozilla-central@f74ad36bb97b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone35.0a1
first release with
nightly linux32
f74ad36bb97b / 35.0a1 / 20141011030203 / files
nightly linux64
f74ad36bb97b / 35.0a1 / 20141011030203 / files
nightly mac
f74ad36bb97b / 35.0a1 / 20141011030203 / files
nightly win32
f74ad36bb97b / 35.0a1 / 20141011030203 / files
nightly win64
f74ad36bb97b / 35.0a1 / 20141011030203 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge inbound to m-c a=merge CLOSED TREE
browser/config/mozconfigs/win64/debug
dom/canvas/test/webgl-conformance/mochi-wrapper.css
gfx/gl/SurfaceStream.cpp
gfx/gl/SurfaceStream.h
memory/replace/dmd/test/full-heap-expected1.txt
memory/replace/dmd/test/full-heap-expected2.txt
memory/replace/dmd/test/full-heap-expected3.txt
memory/replace/dmd/test/full-heap-expected4.txt
memory/replace/dmd/test/full-reports-expected1.txt
memory/replace/dmd/test/full-reports-expected2.txt
memory/replace/dmd/test/full-reports-expected3.txt
memory/replace/dmd/test/full-reports-expected4.txt
mobile/android/base/gfx/NinePatchTileLayer.java
mobile/android/base/gfx/SingleTileLayer.java
mobile/android/base/gfx/TextLayer.java
mobile/android/base/moz.build
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,9 +17,9 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-Bug 1069071: IPDL changes require CLOBBER (second time around)
+Bug 1080922 - Removal of a test manifest that the build system isn't picking up.
--- a/browser/app/nsBrowserApp.cpp
+++ b/browser/app/nsBrowserApp.cpp
@@ -269,20 +269,17 @@ static int do_main(int argc, char* argv[
     if (NS_FAILED(rv)) {
       Output("Couldn't find the application directory.\n");
       return 255;
     }
 
     nsCOMPtr<nsIFile> greDir;
     exeFile->GetParent(getter_AddRefs(greDir));
 #ifdef XP_MACOSX
-    nsCOMPtr<nsIFile> parent;
-    greDir->GetParent(getter_AddRefs(parent));
-    greDir = parent.forget();
-    greDir->AppendNative(NS_LITERAL_CSTRING(kOSXResourcesFolder));
+    greDir->SetNativeLeafName(NS_LITERAL_CSTRING(kOSXResourcesFolder));
 #endif
     nsCOMPtr<nsIFile> appSubdir;
     greDir->Clone(getter_AddRefs(appSubdir));
     appSubdir->Append(NS_LITERAL_STRING(kDesktopFolder));
 
     SetStrongPtr(appData.directory, static_cast<nsIFile*>(appSubdir.get()));
     // xreDirectory already has a refcount from NS_NewLocalFile
     appData.xreDirectory = xreDirectory;
--- a/browser/components/translation/translation-infobar.xml
+++ b/browser/components/translation/translation-infobar.xml
@@ -26,17 +26,18 @@
           <xul:panel anonid="welcomePanel" class="translation-welcome-panel"
                      type="arrow" align="start">
             <xul:image class="translation-welcome-logo"/>
             <xul:vbox flex="1" class="translation-welcome-content">
               <xul:description class="translation-welcome-headline"
                                anonid="welcomeHeadline"/>
               <xul:description class="translation-welcome-body" anonid="welcomeBody"/>
               <xul:hbox align="center">
-                <xul:label anonid="learnMore" class="plain text-link"/>
+                <xul:label anonid="learnMore" class="plain text-link"
+                           onclick="openUILinkIn('https://support.mozilla.org/en-US/products/firefox/automatic-translation', 'tab'); this.parentNode.parentNode.parentNode.hidePopup();"/>
                 <xul:spacer flex="1"/>
                 <xul:button class="translate-infobar-element" anonid="thanksButton"
                             onclick="this.parentNode.parentNode.parentNode.hidePopup();"/>
               </xul:hbox>
             </xul:vbox>
           </xul:panel>
           <xul:deck anonid="translationStates" selectedIndex="0">
 
@@ -210,17 +211,18 @@
 
             if (aTranslation.translatedTo)
               toLanguage.value = aTranslation.translatedTo;
 
             if (aTranslation.state)
               this.state = aTranslation.state;
 
             const kWelcomePref = "browser.translation.ui.welcomeMessageShown";
-            if (Services.prefs.prefHasUserValue(kWelcomePref))
+            if (Services.prefs.prefHasUserValue(kWelcomePref) ||
+                this.translation.browser != gBrowser.selectedBrowser)
               return;
 
             this.addEventListener("transitionend", function onShown() {
               this.removeEventListener("transitionend", onShown);
 
               // These strings are hardcoded because they need to reach beta
               // without riding the trains.
               let localizedStrings = {
--- a/browser/config/mozconfigs/win64/beta
+++ b/browser/config/mozconfigs/win64/beta
@@ -1,10 +1,10 @@
 . "$topsrcdir/build/mozconfig.win-common"
 . "$topsrcdir/browser/config/mozconfigs/win64/common-win64"
 . "$topsrcdir/browser/config/mozconfigs/win64/common-opt"
 
 mk_add_options MOZ_PGO=1
 
 ac_add_options --enable-official-branding
-. $topsrcdir/build/win64/mozconfig.vs2010
+. $topsrcdir/build/win64/mozconfig.vs2013
 
 . "$topsrcdir/build/mozconfig.common.override"
--- a/browser/config/mozconfigs/win64/debug
+++ b/browser/config/mozconfigs/win64/debug
@@ -19,11 +19,11 @@ fi
 ac_add_options --with-google-oauth-api-keyfile=${_google_oauth_api_keyfile}
 
 # Needed to enable breakpad in application.ini
 export MOZILLA_OFFICIAL=1
 
 # Package js shell.
 export MOZ_PACKAGE_JSSHELL=1
 
-. $topsrcdir/build/win64/mozconfig.vs2010
+. $topsrcdir/build/win64/mozconfig.vs2013
 
 . "$topsrcdir/build/mozconfig.common.override"
--- a/browser/config/mozconfigs/win64/nightly
+++ b/browser/config/mozconfigs/win64/nightly
@@ -3,11 +3,11 @@
 . "$topsrcdir/browser/config/mozconfigs/win64/common-opt"
 
 ac_add_options --enable-signmar
 ac_add_options --enable-profiling
 
 # Nightlies only since this has a cost in performance
 ac_add_options --enable-js-diagnostics
 
-. $topsrcdir/build/win64/mozconfig.vs2010
+. $topsrcdir/build/win64/mozconfig.vs2013
 
 . "$topsrcdir/build/mozconfig.common.override"
--- a/browser/config/mozconfigs/win64/release
+++ b/browser/config/mozconfigs/win64/release
@@ -6,11 +6,11 @@
 
 mk_add_options MOZ_PGO=1
 
 ac_add_options --enable-official-branding
 
 # safeguard against someone forgetting to re-set EARLY_BETA_OR_EARLIER in
 # defines.sh during the beta cycle
 export BUILDING_RELEASE=1
-. $topsrcdir/build/win64/mozconfig.vs2010
+. $topsrcdir/build/win64/mozconfig.vs2013
 
 . "$topsrcdir/build/mozconfig.common.override"
--- a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-01.js
+++ b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-01.js
@@ -73,18 +73,18 @@ function testVariablesAndPropertiesFilte
       "The constr2Var should be expanded.");
 
     is(localScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 1,
       "There should be 1 variable displayed in the local scope.");
     is(withScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 0,
       "There should be 0 variables displayed in the with scope.");
     is(functionScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 0,
       "There should be 0 variables displayed in the function scope.");
-    isnot(globalScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 0,
-      "There should be some variables displayed in the global scope.");
+    is(globalScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 0,
+      "There should be 0 variables displayed in the global scope.");
 
     is(withScope.target.querySelectorAll(".variables-view-property:not([unmatched])").length, 0,
       "There should be 0 properties displayed in the with scope.");
     is(functionScope.target.querySelectorAll(".variables-view-property:not([unmatched])").length, 0,
       "There should be 0 properties displayed in the function scope.");
     is(globalScope.target.querySelectorAll(".variables-view-property:not([unmatched])").length, 0,
       "There should be 0 properties displayed in the global scope.");
 
--- a/configure.in
+++ b/configure.in
@@ -3574,17 +3574,17 @@ dnl = If NSS was not detected in the sys
 dnl = use the one in the source tree (mozilla/security/nss)
 dnl ========================================================
 
 MOZ_ARG_WITH_BOOL(system-nss,
 [  --with-system-nss       Use system installed NSS],
     _USE_SYSTEM_NSS=1 )
 
 if test -n "$_USE_SYSTEM_NSS"; then
-    AM_PATH_NSS(3.17.1, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
+    AM_PATH_NSS(3.17.2, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
 fi
 
 if test -n "$MOZ_NATIVE_NSS"; then
    NSS_LIBS="$NSS_LIBS -lcrmf"
 else
    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
 
    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT"; then
--- a/content/base/src/WebSocket.cpp
+++ b/content/base/src/WebSocket.cpp
@@ -1,23 +1,28 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set sw=2 ts=8 et tw=80 : */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #include "WebSocket.h"
 #include "mozilla/dom/WebSocketBinding.h"
+#include "mozilla/net/WebSocketChannel.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "js/OldDebugAPI.h"
 #include "mozilla/DOMEventTargetHelper.h"
+#include "mozilla/net/WebSocketChannel.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/ScriptSettings.h"
+#include "mozilla/dom/WorkerPrivate.h"
+#include "mozilla/dom/WorkerRunnable.h"
+#include "mozilla/dom/WorkerScope.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIDOMWindow.h"
 #include "nsIDocument.h"
 #include "nsXPCOM.h"
 #include "nsIXPConnect.h"
 #include "nsContentUtils.h"
 #include "nsError.h"
 #include "nsIScriptObjectPrincipal.h"
@@ -36,51 +41,336 @@
 #include "nsIScriptError.h"
 #include "nsNetUtil.h"
 #include "nsILoadGroup.h"
 #include "mozilla/Preferences.h"
 #include "xpcpublic.h"
 #include "nsContentPolicyUtils.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsIObserverService.h"
+#include "nsIEventTarget.h"
+#include "nsIInterfaceRequestor.h"
+#include "nsIObserver.h"
+#include "nsIRequest.h"
+#include "nsIThreadRetargetableRequest.h"
 #include "nsIWebSocketChannel.h"
+#include "nsIWebSocketListener.h"
+#include "nsProxyRelease.h"
+#include "nsWeakReference.h"
+
+using namespace mozilla::net;
+using namespace mozilla::dom::workers;
 
 namespace mozilla {
 namespace dom {
 
-#define UTF_8_REPLACEMENT_CHAR    static_cast<char16_t>(0xFFFD)
-
-class CallDispatchConnectionCloseEvents: public nsRunnable
+class WebSocketImpl MOZ_FINAL : public nsIInterfaceRequestor
+                              , public nsIWebSocketListener
+                              , public nsIObserver
+                              , public nsSupportsWeakReference
+                              , public nsIRequest
+                              , public nsIEventTarget
 {
 public:
-  explicit CallDispatchConnectionCloseEvents(WebSocket* aWebSocket)
-    : mWebSocket(aWebSocket)
-  {}
+  NS_DECL_NSIINTERFACEREQUESTOR
+  NS_DECL_NSIWEBSOCKETLISTENER
+  NS_DECL_NSIOBSERVER
+  NS_DECL_NSIREQUEST
+  NS_DECL_THREADSAFE_ISUPPORTS
+  NS_DECL_NSIEVENTTARGET
+
+  WebSocketImpl(WebSocket* aWebSocket)
+  : mWebSocket(aWebSocket)
+  , mOnCloseScheduled(false)
+  , mFailed(false)
+  , mDisconnected(false)
+  , mCloseEventWasClean(false)
+  , mCloseEventCode(nsIWebSocketChannel::CLOSE_ABNORMAL)
+  , mOutgoingBufferedAmount(0)
+  , mBinaryType(dom::BinaryType::Blob)
+  , mScriptLine(0)
+  , mInnerWindowID(0)
+  , mMutex("WebSocketImpl::mMutex")
+  , mWorkerPrivate(nullptr)
+  , mReadyState(WebSocket::CONNECTING)
+  {
+    if (!NS_IsMainThread()) {
+      mWorkerPrivate = GetCurrentThreadWorkerPrivate();
+      MOZ_ASSERT(mWorkerPrivate);
+    }
+  }
+
+  void AssertIsOnTargetThread() const
+  {
+    MOZ_ASSERT(IsTargetThread());
+  }
+
+  bool IsTargetThread() const;
+
+  uint16_t ReadyState()
+  {
+    MutexAutoLock lock(mMutex);
+    return mReadyState;
+  }
+
+  void SetReadyState(uint16_t aReadyState)
+  {
+    MutexAutoLock lock(mMutex);
+    mReadyState = aReadyState;
+  }
+
+  uint32_t BufferedAmount() const
+  {
+    AssertIsOnTargetThread();
+    return mOutgoingBufferedAmount;
+  }
+
+  dom::BinaryType BinaryType() const
+  {
+    AssertIsOnTargetThread();
+    return mBinaryType;
+  }
+
+  void SetBinaryType(dom::BinaryType aData)
+  {
+    AssertIsOnTargetThread();
+    mBinaryType = aData;
+  }
+
+  void GetUrl(nsAString& aURL) const
+  {
+    AssertIsOnTargetThread();
+
+    if (mEffectiveURL.IsEmpty()) {
+      aURL = mOriginalURL;
+    } else {
+      aURL = mEffectiveURL;
+    }
+  }
+
+  void Close(const Optional<uint16_t>& aCode,
+             const Optional<nsAString>& aReason,
+             ErrorResult& aRv);
+
+  void Init(JSContext* aCx,
+            nsIPrincipal* aPrincipal,
+            const nsAString& aURL,
+            nsTArray<nsString>& aProtocolArray,
+            const nsACString& aScriptFile,
+            uint32_t aScriptLine,
+            ErrorResult& aRv,
+            bool* aConnectionFailed);
+
+  void AsyncOpen(ErrorResult& aRv);
+
+  void Send(nsIInputStream* aMsgStream,
+            const nsACString& aMsgString,
+            uint32_t aMsgLength,
+            bool aIsBinary,
+            ErrorResult& aRv);
+
+  nsresult ParseURL(const nsAString& aURL);
+  nsresult InitializeConnection();
+
+  // These methods when called can release the WebSocket object
+  void FailConnection(uint16_t reasonCode,
+                      const nsACString& aReasonString = EmptyCString());
+  nsresult CloseConnection(uint16_t reasonCode,
+                           const nsACString& aReasonString = EmptyCString());
+  nsresult Disconnect();
+  void DisconnectInternal();
+
+  nsresult ConsoleError();
+  nsresult PrintErrorOnConsole(const char* aBundleURI,
+                               const char16_t* aError,
+                               const char16_t** aFormatStrings,
+                               uint32_t aFormatStringsLen);
+
+  nsresult DoOnMessageAvailable(const nsACString& aMsg,
+                                bool isBinary);
+
+  // ConnectionCloseEvents: 'error' event if needed, then 'close' event.
+  // - These must not be dispatched while we are still within an incoming call
+  //   from JS (ex: close()).  Set 'sync' to false in that case to dispatch in a
+  //   separate new event.
+  nsresult ScheduleConnectionCloseEvents(nsISupports* aContext,
+                                         nsresult aStatusCode,
+                                         bool sync);
+  // 2nd half of ScheduleConnectionCloseEvents, sometimes run in its own event.
+  void DispatchConnectionCloseEvents();
+
+  // Dispatch a runnable to the right thread.
+  nsresult DispatchRunnable(nsIRunnable* aRunnable);
+
+  nsresult UpdateURI();
+
+  void AddRefObject();
+  void ReleaseObject();
+
+  void UnregisterFeature();
+
+  nsresult CancelInternal();
+
+  nsRefPtr<WebSocket> mWebSocket;
+
+  nsCOMPtr<nsIWebSocketChannel> mChannel;
+
+  // related to the WebSocket constructor steps
+  nsString mOriginalURL;
+  nsString mEffectiveURL;   // after redirects
+  bool mSecure; // if true it is using SSL and the wss scheme,
+                // otherwise it is using the ws scheme with no SSL
+
+  bool mOnCloseScheduled;
+  bool mFailed;
+  bool mDisconnected;
+
+  // Set attributes of DOM 'onclose' message
+  bool      mCloseEventWasClean;
+  nsString  mCloseEventReason;
+  uint16_t  mCloseEventCode;
+
+  nsCString mAsciiHost;  // hostname
+  uint32_t  mPort;
+  nsCString mResource; // [filepath[?query]]
+  nsString  mUTF16Origin;
+
+  nsCString mURI;
+  nsCString mRequestedProtocolList;
+  nsCString mEstablishedProtocol;
+  nsCString mEstablishedExtensions;
+
+  nsCOMPtr<nsIPrincipal> mPrincipal;
+  nsWeakPtr              mOriginDocument;
+
+  uint32_t mOutgoingBufferedAmount;
+
+  dom::BinaryType mBinaryType;
+
+  // Web Socket owner information:
+  // - the script file name, UTF8 encoded.
+  // - source code line number where the Web Socket object was constructed.
+  // - the ID of the inner window where the script lives. Note that this may not
+  //   be the same as the Web Socket owner window.
+  // These attributes are used for error reporting.
+  nsCString mScriptFile;
+  uint32_t mScriptLine;
+  uint64_t mInnerWindowID;
+
+  // This mutex protects mReadyState that is the only variable that is used in
+  // different threads.
+  mozilla::Mutex mMutex;
+
+  WorkerPrivate* mWorkerPrivate;
+  nsAutoPtr<WorkerFeature> mWorkerFeature;
+
+private:
+  ~WebSocketImpl()
+  {
+    // If we threw during Init we never called disconnect
+    if (!mDisconnected) {
+      Disconnect();
+    }
+  }
+
+  // This value should not be used directly but use ReadyState() instead.
+  uint16_t mReadyState;
+};
+
+NS_IMPL_ISUPPORTS(WebSocketImpl,
+                  nsIInterfaceRequestor,
+                  nsIWebSocketListener,
+                  nsIObserver,
+                  nsISupportsWeakReference,
+                  nsIRequest,
+                  nsIEventTarget)
+
+class CallDispatchConnectionCloseEvents MOZ_FINAL : public nsRunnable
+{
+public:
+  explicit CallDispatchConnectionCloseEvents(WebSocketImpl* aWebSocketImpl)
+    : mWebSocketImpl(aWebSocketImpl)
+  {
+    aWebSocketImpl->AssertIsOnTargetThread();
+  }
 
   NS_IMETHOD Run()
   {
-    mWebSocket->DispatchConnectionCloseEvents();
+    mWebSocketImpl->AssertIsOnTargetThread();
+    mWebSocketImpl->DispatchConnectionCloseEvents();
     return NS_OK;
   }
 
 private:
-  nsRefPtr<WebSocket> mWebSocket;
+  nsRefPtr<WebSocketImpl> mWebSocketImpl;
 };
 
 //-----------------------------------------------------------------------------
-// WebSocket
+// WebSocketImpl
 //-----------------------------------------------------------------------------
 
+namespace {
+
+class PrintErrorOnConsoleRunnable MOZ_FINAL : public WorkerMainThreadRunnable
+{
+public:
+  PrintErrorOnConsoleRunnable(WebSocketImpl* aImpl,
+                              const char* aBundleURI,
+                              const char16_t* aError,
+                              const char16_t** aFormatStrings,
+                              uint32_t aFormatStringsLen)
+    : WorkerMainThreadRunnable(aImpl->mWorkerPrivate)
+    , mImpl(aImpl)
+    , mBundleURI(aBundleURI)
+    , mError(aError)
+    , mFormatStrings(aFormatStrings)
+    , mFormatStringsLen(aFormatStringsLen)
+    , mRv(NS_ERROR_FAILURE)
+  { }
+
+  bool MainThreadRun() MOZ_OVERRIDE
+  {
+    mRv = mImpl->PrintErrorOnConsole(mBundleURI, mError, mFormatStrings,
+                                     mFormatStringsLen);
+    return true;
+  }
+
+  nsresult ErrorCode() const
+  {
+    return mRv;
+  }
+
+private:
+  // Raw pointer because this runnable is sync.
+  WebSocketImpl* mImpl;
+
+  const char* mBundleURI;
+  const char16_t* mError;
+  const char16_t** mFormatStrings;
+  uint32_t mFormatStringsLen;
+  nsresult mRv;
+};
+
+} // anonymous namespace
+
 nsresult
-WebSocket::PrintErrorOnConsole(const char *aBundleURI,
-                               const char16_t *aError,
-                               const char16_t **aFormatStrings,
-                               uint32_t aFormatStringsLen)
+WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI,
+                                   const char16_t *aError,
+                                   const char16_t **aFormatStrings,
+                                   uint32_t aFormatStringsLen)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  // This method must run on the main thread.
+
+  if (!NS_IsMainThread()) {
+    nsRefPtr<PrintErrorOnConsoleRunnable> runnable =
+      new PrintErrorOnConsoleRunnable(this, aBundleURI, aError, aFormatStrings,
+                                      aFormatStringsLen);
+    runnable->Dispatch(mWorkerPrivate->GetJSContext());
+    return runnable->ErrorCode();
+  }
 
   nsresult rv;
   nsCOMPtr<nsIStringBundleService> bundleService =
     do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIStringBundle> strBundle;
   rv = bundleService->CreateBundle(aBundleURI, getter_AddRefs(strBundle));
@@ -114,227 +404,331 @@ WebSocket::PrintErrorOnConsole(const cha
 
   // print the error message directly to the JS console
   rv = console->LogMessage(errorObject);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
-nsresult
-WebSocket::CloseConnection(uint16_t aReasonCode,
-                             const nsACString& aReasonString)
+namespace {
+
+class CloseRunnable MOZ_FINAL : public WorkerMainThreadRunnable
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-  if (mReadyState == WebSocket::CLOSING ||
-      mReadyState == WebSocket::CLOSED) {
+public:
+  CloseRunnable(WebSocketImpl* aImpl, uint16_t aReasonCode,
+                const nsACString& aReasonString)
+    : WorkerMainThreadRunnable(aImpl->mWorkerPrivate)
+    , mImpl(aImpl)
+    , mReasonCode(aReasonCode)
+    , mReasonString(aReasonString)
+    , mRv(NS_ERROR_FAILURE)
+  { }
+
+  bool MainThreadRun() MOZ_OVERRIDE
+  {
+    mRv = mImpl->mChannel->Close(mReasonCode, mReasonString);
+    return true;
+  }
+
+  nsresult ErrorCode() const
+  {
+    return mRv;
+  }
+
+private:
+  // A raw pointer because this runnable is sync.
+  WebSocketImpl* mImpl;
+
+  uint16_t mReasonCode;
+  const nsACString& mReasonString;
+  nsresult mRv;
+};
+
+} // anonymous namespace
+
+nsresult
+WebSocketImpl::CloseConnection(uint16_t aReasonCode,
+                               const nsACString& aReasonString)
+{
+  AssertIsOnTargetThread();
+
+  uint16_t readyState = ReadyState();
+  if (readyState == WebSocket::CLOSING ||
+      readyState == WebSocket::CLOSED) {
     return NS_OK;
   }
 
   // The common case...
   if (mChannel) {
-    mReadyState = WebSocket::CLOSING;
-    return mChannel->Close(aReasonCode, aReasonString);
+    SetReadyState(WebSocket::CLOSING);
+
+    // The channel has to be closed on the main-thread.
+
+    if (NS_IsMainThread()) {
+      return mChannel->Close(aReasonCode, aReasonString);
+    }
+
+    nsRefPtr<CloseRunnable> runnable =
+      new CloseRunnable(this, aReasonCode, aReasonString);
+    runnable->Dispatch(mWorkerPrivate->GetJSContext());
+    return runnable->ErrorCode();
   }
 
   // No channel, but not disconnected: canceled or failed early
   //
-  MOZ_ASSERT(mReadyState == WebSocket::CONNECTING,
+  MOZ_ASSERT(readyState == WebSocket::CONNECTING,
              "Should only get here for early websocket cancel/error");
 
   // Server won't be sending us a close code, so use what's passed in here.
   mCloseEventCode = aReasonCode;
   CopyUTF8toUTF16(aReasonString, mCloseEventReason);
 
-  mReadyState = WebSocket::CLOSING;
+  SetReadyState(WebSocket::CLOSING);
 
   // Can be called from Cancel() or Init() codepaths, so need to dispatch
   // onerror/onclose asynchronously
   ScheduleConnectionCloseEvents(
                     nullptr,
                     (aReasonCode == nsIWebSocketChannel::CLOSE_NORMAL ||
                      aReasonCode == nsIWebSocketChannel::CLOSE_GOING_AWAY) ?
                      NS_OK : NS_ERROR_FAILURE,
                     false);
 
   return NS_OK;
 }
 
 nsresult
-WebSocket::ConsoleError()
+WebSocketImpl::ConsoleError()
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-
-  nsAutoCString targetSpec;
-  nsresult rv = mURI->GetSpec(targetSpec);
-  if (NS_FAILED(rv)) {
-    NS_WARNING("Failed to get targetSpec");
+  AssertIsOnTargetThread();
+
+  NS_ConvertUTF8toUTF16 specUTF16(mURI);
+  const char16_t* formatStrings[] = { specUTF16.get() };
+
+  if (ReadyState() < WebSocket::OPEN) {
+    PrintErrorOnConsole("chrome://global/locale/appstrings.properties",
+                        MOZ_UTF16("connectionFailure"),
+                        formatStrings, ArrayLength(formatStrings));
   } else {
-    NS_ConvertUTF8toUTF16 specUTF16(targetSpec);
-    const char16_t* formatStrings[] = { specUTF16.get() };
-
-    if (mReadyState < WebSocket::OPEN) {
-      PrintErrorOnConsole("chrome://global/locale/appstrings.properties",
-                          MOZ_UTF16("connectionFailure"),
-                          formatStrings, ArrayLength(formatStrings));
-    } else {
-      PrintErrorOnConsole("chrome://global/locale/appstrings.properties",
-                          MOZ_UTF16("netInterrupt"),
-                          formatStrings, ArrayLength(formatStrings));
-    }
+    PrintErrorOnConsole("chrome://global/locale/appstrings.properties",
+                        MOZ_UTF16("netInterrupt"),
+                        formatStrings, ArrayLength(formatStrings));
   }
   /// todo some specific errors - like for message too large
-  return rv;
+  return NS_OK;
 }
 
-
 void
-WebSocket::FailConnection(uint16_t aReasonCode,
-                          const nsACString& aReasonString)
+WebSocketImpl::FailConnection(uint16_t aReasonCode,
+                              const nsACString& aReasonString)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  AssertIsOnTargetThread();
 
   ConsoleError();
   mFailed = true;
   CloseConnection(aReasonCode, aReasonString);
 }
 
+namespace {
+
+class DisconnectInternalRunnable MOZ_FINAL : public WorkerMainThreadRunnable
+{
+public:
+  DisconnectInternalRunnable(WebSocketImpl* aImpl)
+    : WorkerMainThreadRunnable(aImpl->mWorkerPrivate)
+    , mImpl(aImpl)
+  { }
+
+  bool MainThreadRun() MOZ_OVERRIDE
+  {
+    mImpl->DisconnectInternal();
+    return true;
+  }
+
+private:
+  // A raw pointer because this runnable is sync.
+  WebSocketImpl* mImpl;
+};
+
+} // anonymous namespace
+
 nsresult
-WebSocket::Disconnect()
+WebSocketImpl::Disconnect()
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-
-  if (mDisconnected)
+  if (mDisconnected) {
     return NS_OK;
+  }
+
+  AssertIsOnTargetThread();
+
+  // DisconnectInternal touches observers and nsILoadGroup and it must run on
+  // the main thread.
+
+  if (NS_IsMainThread()) {
+    DisconnectInternal();
+  } else {
+    nsRefPtr<DisconnectInternalRunnable> runnable =
+      new DisconnectInternalRunnable(this);
+    runnable->Dispatch(mWorkerPrivate->GetJSContext());
+  }
+
+  // DontKeepAliveAnyMore() can release the object. So hold a reference to this
+  // until the end of the method.
+  nsRefPtr<WebSocketImpl> kungfuDeathGrip = this;
+
+  if (mWorkerPrivate && mWorkerFeature) {
+    UnregisterFeature();
+  }
+
+  nsCOMPtr<nsIThread> mainThread;
+  if (NS_FAILED(NS_GetMainThread(getter_AddRefs(mainThread))) ||
+      NS_FAILED(NS_ProxyRelease(mainThread, mChannel))) {
+    NS_WARNING("Failed to proxy release of channel, leaking instead!");
+  }
+
+  mDisconnected = true;
+  mWebSocket->DontKeepAliveAnyMore();
+  mWebSocket->mImpl = nullptr;
+
+  // We want to release the WebSocket in the correct thread.
+  mWebSocket = nullptr;
+
+  return NS_OK;
+}
+
+void
+WebSocketImpl::DisconnectInternal()
+{
+  AssertIsOnMainThread();
 
   nsCOMPtr<nsILoadGroup> loadGroup;
   GetLoadGroup(getter_AddRefs(loadGroup));
-  if (loadGroup)
+  if (loadGroup) {
     loadGroup->RemoveRequest(this, nullptr, NS_OK);
+  }
 
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os) {
     os->RemoveObserver(this, DOM_WINDOW_DESTROYED_TOPIC);
     os->RemoveObserver(this, DOM_WINDOW_FROZEN_TOPIC);
   }
-
-  // DontKeepAliveAnyMore() can release the object. So hold a reference to this
-  // until the end of the method.
-  nsRefPtr<WebSocket> kungfuDeathGrip = this;
-
-  DontKeepAliveAnyMore();
-  mChannel = nullptr;
-  mDisconnected = true;
-
-  return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
-// WebSocket::nsIWebSocketListener methods:
+// WebSocketImpl::nsIWebSocketListener methods:
 //-----------------------------------------------------------------------------
 
 nsresult
-WebSocket::DoOnMessageAvailable(const nsACString& aMsg, bool isBinary)
+WebSocketImpl::DoOnMessageAvailable(const nsACString& aMsg, bool isBinary)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-
-  if (mReadyState == WebSocket::CLOSED) {
+  AssertIsOnTargetThread();
+
+  int16_t readyState = ReadyState();
+  if (readyState == WebSocket::CLOSED) {
     NS_ERROR("Received message after CLOSED");
     return NS_ERROR_UNEXPECTED;
   }
 
-  if (mReadyState == WebSocket::OPEN) {
+  if (readyState == WebSocket::OPEN) {
     // Dispatch New Message
-    nsresult rv = CreateAndDispatchMessageEvent(aMsg, isBinary);
+    nsresult rv = mWebSocket->CreateAndDispatchMessageEvent(aMsg, isBinary);
     if (NS_FAILED(rv)) {
       NS_WARNING("Failed to dispatch the message event");
     }
   } else {
     // CLOSING should be the only other state where it's possible to get msgs
     // from channel: Spec says to drop them.
-    MOZ_ASSERT(mReadyState == WebSocket::CLOSING,
+    MOZ_ASSERT(readyState == WebSocket::CLOSING,
                "Received message while CONNECTING or CLOSED");
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-WebSocket::OnMessageAvailable(nsISupports* aContext, const nsACString& aMsg)
+WebSocketImpl::OnMessageAvailable(nsISupports* aContext,
+                                  const nsACString& aMsg)
 {
+  AssertIsOnTargetThread();
   return DoOnMessageAvailable(aMsg, false);
 }
 
 NS_IMETHODIMP
-WebSocket::OnBinaryMessageAvailable(nsISupports* aContext,
-                                    const nsACString& aMsg)
+WebSocketImpl::OnBinaryMessageAvailable(nsISupports* aContext,
+                                        const nsACString& aMsg)
 {
+  AssertIsOnTargetThread();
   return DoOnMessageAvailable(aMsg, true);
 }
 
 NS_IMETHODIMP
-WebSocket::OnStart(nsISupports* aContext)
+WebSocketImpl::OnStart(nsISupports* aContext)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  AssertIsOnTargetThread();
+
+  int16_t readyState = ReadyState();
 
   // This is the only function that sets OPEN, and should be called only once
-  MOZ_ASSERT(mReadyState != WebSocket::OPEN,
+  MOZ_ASSERT(readyState != WebSocket::OPEN,
              "readyState already OPEN! OnStart called twice?");
 
   // Nothing to do if we've already closed/closing
-  if (mReadyState != WebSocket::CONNECTING) {
+  if (readyState != WebSocket::CONNECTING) {
     return NS_OK;
   }
 
   // Attempt to kill "ghost" websocket: but usually too early for check to fail
-  nsresult rv = CheckInnerWindowCorrectness();
+  nsresult rv = mWebSocket->CheckInnerWindowCorrectness();
   if (NS_FAILED(rv)) {
     CloseConnection(nsIWebSocketChannel::CLOSE_GOING_AWAY);
     return rv;
   }
 
   if (!mRequestedProtocolList.IsEmpty()) {
     mChannel->GetProtocol(mEstablishedProtocol);
   }
 
   mChannel->GetExtensions(mEstablishedExtensions);
   UpdateURI();
 
-  mReadyState = WebSocket::OPEN;
+  SetReadyState(WebSocket::OPEN);
 
   // Call 'onopen'
-  rv = CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("open"));
+  rv = mWebSocket->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("open"));
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to dispatch the open event");
   }
 
-  UpdateMustKeepAlive();
+  mWebSocket->UpdateMustKeepAlive();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-WebSocket::OnStop(nsISupports* aContext, nsresult aStatusCode)
+WebSocketImpl::OnStop(nsISupports* aContext, nsresult aStatusCode)
 {
+  AssertIsOnTargetThread();
+
   // We can be CONNECTING here if connection failed.
   // We can be OPEN if we have encountered a fatal protocol error
   // We can be CLOSING if close() was called and/or server initiated close.
-  MOZ_ASSERT(mReadyState != WebSocket::CLOSED,
+  MOZ_ASSERT(ReadyState() != WebSocket::CLOSED,
              "Shouldn't already be CLOSED when OnStop called");
 
   // called by network stack, not JS, so can dispatch JS events synchronously
   return ScheduleConnectionCloseEvents(aContext, aStatusCode, true);
 }
 
 nsresult
-WebSocket::ScheduleConnectionCloseEvents(nsISupports* aContext,
-                                         nsresult aStatusCode,
-                                         bool sync)
+WebSocketImpl::ScheduleConnectionCloseEvents(nsISupports* aContext,
+                                             nsresult aStatusCode,
+                                             bool sync)
 {
-  MOZ_ASSERT(NS_IsMainThread());
+  AssertIsOnTargetThread();
 
   // no-op if some other code has already initiated close event
   if (!mOnCloseScheduled) {
     mCloseEventWasClean = NS_SUCCEEDED(aStatusCode);
 
     if (aStatusCode == NS_BASE_STREAM_CLOSED) {
       // don't generate an error event just because of an unclean close
       aStatusCode = NS_OK;
@@ -353,80 +747,85 @@ WebSocket::ScheduleConnectionCloseEvents
       NS_DispatchToCurrentThread(new CallDispatchConnectionCloseEvents(this));
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-WebSocket::OnAcknowledge(nsISupports *aContext, uint32_t aSize)
+WebSocketImpl::OnAcknowledge(nsISupports *aContext, uint32_t aSize)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-
-  if (aSize > mOutgoingBufferedAmount)
+  AssertIsOnTargetThread();
+
+  if (aSize > mOutgoingBufferedAmount) {
     return NS_ERROR_UNEXPECTED;
+  }
 
   mOutgoingBufferedAmount -= aSize;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-WebSocket::OnServerClose(nsISupports *aContext, uint16_t aCode,
-                           const nsACString &aReason)
+WebSocketImpl::OnServerClose(nsISupports *aContext, uint16_t aCode,
+                             const nsACString &aReason)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-
-  MOZ_ASSERT(mReadyState != WebSocket::CONNECTING,
+  AssertIsOnTargetThread();
+
+  int16_t readyState = ReadyState();
+
+  MOZ_ASSERT(readyState != WebSocket::CONNECTING,
              "Received server close before connected?");
-  MOZ_ASSERT(mReadyState != WebSocket::CLOSED,
+  MOZ_ASSERT(readyState != WebSocket::CLOSED,
              "Received server close after already closed!");
 
   // store code/string for onclose DOM event
   mCloseEventCode = aCode;
   CopyUTF8toUTF16(aReason, mCloseEventReason);
 
-  if (mReadyState == WebSocket::OPEN) {
+  if (readyState == WebSocket::OPEN) {
     // Server initiating close.
     // RFC 6455, 5.5.1: "When sending a Close frame in response, the endpoint
     // typically echos the status code it received".
     // But never send certain codes, per section 7.4.1
     if (aCode == 1005 || aCode == 1006 || aCode == 1015) {
       CloseConnection(0, EmptyCString());
     } else {
       CloseConnection(aCode, aReason);
     }
   } else {
     // We initiated close, and server has replied: OnStop does rest of the work.
-    MOZ_ASSERT(mReadyState == WebSocket::CLOSING, "unknown state");
+    MOZ_ASSERT(readyState == WebSocket::CLOSING, "unknown state");
   }
 
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
-// WebSocket::nsIInterfaceRequestor
+// WebSocketImpl::nsIInterfaceRequestor
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
-WebSocket::GetInterface(const nsIID& aIID, void** aResult)
+WebSocketImpl::GetInterface(const nsIID& aIID, void** aResult)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-
-  if (mReadyState == WebSocket::CLOSED)
+  AssertIsOnMainThread();
+
+  if (ReadyState() == WebSocket::CLOSED) {
     return NS_ERROR_FAILURE;
+  }
 
   if (aIID.Equals(NS_GET_IID(nsIAuthPrompt)) ||
       aIID.Equals(NS_GET_IID(nsIAuthPrompt2))) {
     nsresult rv;
-    nsIScriptContext* sc = GetContextForEventHandlers(&rv);
+    nsIScriptContext* sc = mWebSocket->GetContextForEventHandlers(&rv);
     nsCOMPtr<nsIDocument> doc =
       nsContentUtils::GetDocumentFromScriptContext(sc);
-    if (!doc)
+    if (!doc) {
       return NS_ERROR_NOT_AVAILABLE;
+    }
 
     nsCOMPtr<nsIPromptFactory> wwatch =
       do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsPIDOMWindow> outerWindow = doc->GetWindow();
     return wwatch->GetPrompt(outerWindow, aIID, aResult);
   }
@@ -434,43 +833,27 @@ WebSocket::GetInterface(const nsIID& aII
   return QueryInterface(aIID, aResult);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // WebSocket
 ////////////////////////////////////////////////////////////////////////////////
 
 WebSocket::WebSocket(nsPIDOMWindow* aOwnerWindow)
-: DOMEventTargetHelper(aOwnerWindow),
-  mKeepingAlive(false),
-  mCheckMustKeepAlive(true),
-  mOnCloseScheduled(false),
-  mFailed(false),
-  mDisconnected(false),
-  mCloseEventWasClean(false),
-  mCloseEventCode(nsIWebSocketChannel::CLOSE_ABNORMAL),
-  mReadyState(WebSocket::CONNECTING),
-  mOutgoingBufferedAmount(0),
-  mBinaryType(dom::BinaryType::Blob),
-  mScriptLine(0),
-  mInnerWindowID(0)
+  : DOMEventTargetHelper(aOwnerWindow)
+  , mWorkerPrivate(nullptr)
+  , mKeepingAlive(false)
+  , mCheckMustKeepAlive(true)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-  MOZ_ASSERT(aOwnerWindow);
-  MOZ_ASSERT(aOwnerWindow->IsInnerWindow());
+  mImpl = new WebSocketImpl(this);
+  mWorkerPrivate = mImpl->mWorkerPrivate;
 }
 
 WebSocket::~WebSocket()
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-
-  // If we threw during Init we never called disconnect
-  if (!mDisconnected) {
-    Disconnect();
-  }
 }
 
 JSObject*
 WebSocket::WrapObject(JSContext* cx)
 {
   return WebSocketBinding::Wrap(cx, this);
 }
 
@@ -494,50 +877,172 @@ WebSocket::Constructor(const GlobalObjec
                        const nsAString& aProtocol,
                        ErrorResult& aRv)
 {
   Sequence<nsString> protocols;
   protocols.AppendElement(aProtocol);
   return WebSocket::Constructor(aGlobal, aUrl, protocols, aRv);
 }
 
+namespace {
+
+// This class is used to clear any exception.
+class MOZ_STACK_CLASS ClearException
+{
+public:
+  explicit ClearException(JSContext* aCx)
+    : mCx(aCx)
+  {
+  }
+
+  ~ClearException()
+  {
+    JS_ClearPendingException(mCx);
+  }
+
+private:
+  JSContext* mCx;
+};
+
+class InitRunnable MOZ_FINAL : public WorkerMainThreadRunnable
+{
+public:
+  InitRunnable(WebSocketImpl* aImpl, const nsAString& aURL,
+               nsTArray<nsString>& aProtocolArray,
+               const nsACString& aScriptFile, uint32_t aScriptLine,
+               ErrorResult& aRv, bool* aConnectionFailed)
+    : WorkerMainThreadRunnable(aImpl->mWorkerPrivate)
+    , mImpl(aImpl)
+    , mURL(aURL)
+    , mProtocolArray(aProtocolArray)
+    , mScriptFile(aScriptFile)
+    , mScriptLine(aScriptLine)
+    , mRv(aRv)
+    , mConnectionFailed(aConnectionFailed)
+  {
+    MOZ_ASSERT(mWorkerPrivate);
+    mWorkerPrivate->AssertIsOnWorkerThread();
+  }
+
+  bool MainThreadRun() MOZ_OVERRIDE
+  {
+    AssertIsOnMainThread();
+
+    // Walk up to our containing page
+    WorkerPrivate* wp = mWorkerPrivate;
+    while (wp->GetParent()) {
+      wp = wp->GetParent();
+    }
+
+    nsPIDOMWindow* window = wp->GetWindow();
+    if (!window) {
+      mRv.Throw(NS_ERROR_FAILURE);
+      return true;
+    }
+
+    AutoJSAPI jsapi;
+    if (NS_WARN_IF(!jsapi.Init(window))) {
+      mRv.Throw(NS_ERROR_FAILURE);
+      return true;
+    }
+
+    ClearException ce(jsapi.cx());
+
+    nsIDocument* doc = window->GetExtantDoc();
+    if (!doc) {
+      mRv.Throw(NS_ERROR_FAILURE);
+      return true;
+    }
+
+    nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
+    if (!principal) {
+      mRv.Throw(NS_ERROR_FAILURE);
+      return true;
+    }
+
+    mImpl->Init(jsapi.cx(), principal, mURL, mProtocolArray, mScriptFile,
+                mScriptLine, mRv, mConnectionFailed);
+    return true;
+  }
+
+private:
+  // Raw pointer. This worker runs synchronously.
+  WebSocketImpl* mImpl;
+
+  const nsAString& mURL;
+  nsTArray<nsString>& mProtocolArray;
+  nsCString mScriptFile;
+  uint32_t mScriptLine;
+  ErrorResult& mRv;
+  bool* mConnectionFailed;
+};
+
+class AsyncOpenRunnable MOZ_FINAL : public WorkerMainThreadRunnable
+{
+public:
+  AsyncOpenRunnable(WebSocketImpl* aImpl, ErrorResult& aRv)
+    : WorkerMainThreadRunnable(aImpl->mWorkerPrivate)
+    , mImpl(aImpl)
+    , mRv(aRv)
+  {
+    MOZ_ASSERT(mWorkerPrivate);
+    mWorkerPrivate->AssertIsOnWorkerThread();
+  }
+
+  bool MainThreadRun() MOZ_OVERRIDE
+  {
+    AssertIsOnMainThread();
+    mImpl->AsyncOpen(mRv);
+    return true;
+  }
+
+private:
+  // Raw pointer. This worker runs synchronously.
+  WebSocketImpl* mImpl;
+
+  ErrorResult& mRv;
+};
+
+} // anonymous namespace
+
 already_AddRefed<WebSocket>
 WebSocket::Constructor(const GlobalObject& aGlobal,
                        const nsAString& aUrl,
                        const Sequence<nsString>& aProtocols,
                        ErrorResult& aRv)
 {
-  if (!PrefEnabled()) {
-    aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIScriptObjectPrincipal> scriptPrincipal =
-    do_QueryInterface(aGlobal.GetAsSupports());
-  if (!scriptPrincipal) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIPrincipal> principal = scriptPrincipal->GetPrincipal();
-  if (!principal) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aGlobal.GetAsSupports());
-  if (!sgo) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsPIDOMWindow> ownerWindow = do_QueryInterface(aGlobal.GetAsSupports());
-  if (!ownerWindow) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
+  nsCOMPtr<nsIPrincipal> principal;
+  nsCOMPtr<nsPIDOMWindow> ownerWindow;
+
+  if (NS_IsMainThread()) {
+    nsCOMPtr<nsIScriptObjectPrincipal> scriptPrincipal =
+      do_QueryInterface(aGlobal.GetAsSupports());
+    if (!scriptPrincipal) {
+      aRv.Throw(NS_ERROR_FAILURE);
+      return nullptr;
+    }
+
+    principal = scriptPrincipal->GetPrincipal();
+    if (!principal) {
+      aRv.Throw(NS_ERROR_FAILURE);
+      return nullptr;
+    }
+
+    nsCOMPtr<nsIScriptGlobalObject> sgo =
+      do_QueryInterface(aGlobal.GetAsSupports());
+    if (!sgo) {
+      aRv.Throw(NS_ERROR_FAILURE);
+      return nullptr;
+    }
+
+    ownerWindow = do_QueryInterface(aGlobal.GetAsSupports());
+    if (!ownerWindow) {
+      aRv.Throw(NS_ERROR_FAILURE);
+      return nullptr;
+    }
   }
 
   nsTArray<nsString> protocolArray;
 
   for (uint32_t index = 0, len = aProtocols.Length(); index < len; ++index) {
 
     const nsString& protocolElement = aProtocols[index];
 
@@ -553,31 +1058,109 @@ WebSocket::Constructor(const GlobalObjec
       aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
       return nullptr;
     }
 
     protocolArray.AppendElement(protocolElement);
   }
 
   nsRefPtr<WebSocket> webSocket = new WebSocket(ownerWindow);
-  nsresult rv = webSocket->Init(aGlobal.Context(), principal,
-                                aUrl, protocolArray);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
+  nsRefPtr<WebSocketImpl> kungfuDeathGrip = webSocket->mImpl;
+
+  bool connectionFailed = true;
+
+  if (NS_IsMainThread()) {
+    webSocket->mImpl->Init(aGlobal.Context(), principal, aUrl, protocolArray,
+                           EmptyCString(), 0, aRv, &connectionFailed);
+  } else {
+    unsigned lineno;
+    JS::AutoFilename file;
+    if (!JS::DescribeScriptedCaller(aGlobal.Context(), &file, &lineno)) {
+      NS_WARNING("Failed to get line number and filename in workers.");
+    }
+
+    nsRefPtr<InitRunnable> runnable =
+      new InitRunnable(webSocket->mImpl, aUrl, protocolArray,
+                       nsAutoCString(file.get()), lineno, aRv,
+                       &connectionFailed);
+    runnable->Dispatch(aGlobal.Context());
+  }
+
+  if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
+  // We don't return an error if the connection just failed. Instead we dispatch
+  // an event.
+  if (connectionFailed) {
+    webSocket->mImpl->FailConnection(nsIWebSocketChannel::CLOSE_ABNORMAL);
+  }
+
+  // If we don't have a channel, the connection is failed and onerror() will be
+  // called asynchrounsly.
+  if (!webSocket->mImpl->mChannel) {
+    return webSocket.forget();
+  }
+
+  class MOZ_STACK_CLASS ClearWebSocket
+  {
+  public:
+    ClearWebSocket(WebSocketImpl* aWebSocketImpl)
+      : mWebSocketImpl(aWebSocketImpl)
+      , mDone(false)
+    {
+    }
+
+    void Done()
+    {
+       mDone = true;
+    }
+
+    ~ClearWebSocket()
+    {
+      if (!mDone) {
+        mWebSocketImpl->mChannel = nullptr;
+        mWebSocketImpl->FailConnection(nsIWebSocketChannel::CLOSE_ABNORMAL);
+      }
+    }
+
+    WebSocketImpl* mWebSocketImpl;
+    bool mDone;
+  };
+
+  ClearWebSocket cws(webSocket->mImpl);
+
+  // This operation must be done on the correct thread. The rest must run on the
+  // main-thread.
+  aRv = webSocket->mImpl->mChannel->SetNotificationCallbacks(webSocket->mImpl);
+  if (NS_WARN_IF(aRv.Failed())) {
+    return nullptr;
+  }
+
+  if (NS_IsMainThread()) {
+    webSocket->mImpl->AsyncOpen(aRv);
+  } else {
+    nsRefPtr<AsyncOpenRunnable> runnable =
+      new AsyncOpenRunnable(webSocket->mImpl, aRv);
+    runnable->Dispatch(aGlobal.Context());
+  }
+
+  if (NS_WARN_IF(aRv.Failed())) {
+    return nullptr;
+  }
+
+  cws.Done();
   return webSocket.forget();
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(WebSocket)
 
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(WebSocket)
   bool isBlack = tmp->IsBlack();
-  if (isBlack|| tmp->mKeepingAlive) {
+  if (isBlack || tmp->mKeepingAlive) {
     if (tmp->mListenerManager) {
       tmp->mListenerManager->MarkForCC();
     }
     if (!isBlack && tmp->PreservingWrapper()) {
       // This marks the wrapper black.
       tmp->GetWrapper();
     }
     return true;
@@ -593,209 +1176,284 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_B
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(WebSocket,
                                                DOMEventTargetHelper)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(WebSocket,
                                                   DOMEventTargetHelper)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrincipal)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mURI)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChannel)
+  if (tmp->mImpl) {
+    NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImpl->mPrincipal)
+    NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImpl->mChannel)
+  }
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(WebSocket,
                                                 DOMEventTargetHelper)
-  tmp->Disconnect();
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mPrincipal)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mURI)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mChannel)
+  if (tmp->mImpl) {
+    NS_IMPL_CYCLE_COLLECTION_UNLINK(mImpl->mPrincipal)
+    NS_IMPL_CYCLE_COLLECTION_UNLINK(mImpl->mChannel)
+    tmp->mImpl->Disconnect();
+    MOZ_ASSERT(!tmp->mImpl);
+  }
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(WebSocket)
-  NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
-  NS_INTERFACE_MAP_ENTRY(nsIWebSocketListener)
-  NS_INTERFACE_MAP_ENTRY(nsIObserver)
-  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-  NS_INTERFACE_MAP_ENTRY(nsIRequest)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
 
 NS_IMPL_ADDREF_INHERITED(WebSocket, DOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(WebSocket, DOMEventTargetHelper)
 
 void
 WebSocket::DisconnectFromOwner()
 {
+  AssertIsOnMainThread();
   DOMEventTargetHelper::DisconnectFromOwner();
-  CloseConnection(nsIWebSocketChannel::CLOSE_GOING_AWAY);
+
+  if (mImpl) {
+    mImpl->CloseConnection(nsIWebSocketChannel::CLOSE_GOING_AWAY);
+  }
+
   DontKeepAliveAnyMore();
 }
 
 //-----------------------------------------------------------------------------
-// WebSocket:: initialization
+// WebSocketImpl:: initialization
 //-----------------------------------------------------------------------------
 
-nsresult
-WebSocket::Init(JSContext* aCx,
-                nsIPrincipal* aPrincipal,
-                const nsAString& aURL,
-                nsTArray<nsString>& aProtocolArray)
+void
+WebSocketImpl::Init(JSContext* aCx,
+                    nsIPrincipal* aPrincipal,
+                    const nsAString& aURL,
+                    nsTArray<nsString>& aProtocolArray,
+                    const nsACString& aScriptFile,
+                    uint32_t aScriptLine,
+                    ErrorResult& aRv,
+                    bool* aConnectionFailed)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  AssertIsOnMainThread();
   MOZ_ASSERT(aPrincipal);
 
-  if (!PrefEnabled()) {
-    return NS_ERROR_DOM_SECURITY_ERR;
-  }
+  // We need to keep the implementation alive in case the init disconnects it
+  // because of some error.
+  nsRefPtr<WebSocketImpl> kungfuDeathGrip = this;
 
   mPrincipal = aPrincipal;
 
   // Attempt to kill "ghost" websocket: but usually too early for check to fail
-  nsresult rv = CheckInnerWindowCorrectness();
-  NS_ENSURE_SUCCESS(rv, rv);
+  aRv = mWebSocket->CheckInnerWindowCorrectness();
+  if (NS_WARN_IF(aRv.Failed())) {
+    return;
+  }
 
   // Shut down websocket if window is frozen or destroyed (only needed for
   // "ghost" websockets--see bug 696085)
-  nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
-  NS_ENSURE_STATE(os);
-  rv = os->AddObserver(this, DOM_WINDOW_DESTROYED_TOPIC, true);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = os->AddObserver(this, DOM_WINDOW_FROZEN_TOPIC, true);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  unsigned lineno;
-  JS::AutoFilename file;
-  if (JS::DescribeScriptedCaller(aCx, &file, &lineno)) {
-    mScriptFile = file.get();
-    mScriptLine = lineno;
+  if (!mWorkerPrivate) {
+    nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
+    if (NS_WARN_IF(!os)) {
+      aRv.Throw(NS_ERROR_FAILURE);
+      return;
+    }
+
+    aRv = os->AddObserver(this, DOM_WINDOW_DESTROYED_TOPIC, true);
+    if (NS_WARN_IF(aRv.Failed())) {
+      return;
+    }
+
+    aRv = os->AddObserver(this, DOM_WINDOW_FROZEN_TOPIC, true);
+    if (NS_WARN_IF(aRv.Failed())) {
+      return;
+    }
+  }
+
+  if (mWorkerPrivate) {
+    mScriptFile = aScriptFile;
+    mScriptLine = aScriptLine;
+  } else {
+    unsigned lineno;
+    JS::AutoFilename file;
+    if (JS::DescribeScriptedCaller(aCx, &file, &lineno)) {
+      mScriptFile = file.get();
+      mScriptLine = lineno;
+    }
   }
 
   // Get WindowID
   mInnerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(aCx);
 
   // parses the url
-  rv = ParseURL(PromiseFlatString(aURL));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsIScriptContext* sc = GetContextForEventHandlers(&rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  aRv = ParseURL(PromiseFlatString(aURL));
+  if (NS_WARN_IF(aRv.Failed())) {
+    return;
+  }
+
+  nsIScriptContext* sc = nullptr;
+  {
+    nsresult rv;
+    sc = mWebSocket->GetContextForEventHandlers(&rv);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      aRv.Throw(rv);
+      return;
+    }
+  }
 
   // Don't allow https:// to open ws://
   if (!mSecure &&
       !Preferences::GetBool("network.websocket.allowInsecureFromHTTPS",
                             false)) {
     // Confirmed we are opening plain ws:// and want to prevent this from a
     // secure context (e.g. https). Check the principal's uri to determine if
     // we were loaded from https.
     nsCOMPtr<nsIGlobalObject> globalObject(GetEntryGlobal());
     if (globalObject) {
       nsCOMPtr<nsIPrincipal> principal(globalObject->PrincipalOrNull());
       if (principal) {
         nsCOMPtr<nsIURI> uri;
         principal->GetURI(getter_AddRefs(uri));
         if (uri) {
           bool originIsHttps = false;
-          rv = uri->SchemeIs("https", &originIsHttps);
-          NS_ENSURE_SUCCESS(rv,rv);
+          aRv = uri->SchemeIs("https", &originIsHttps);
+          if (NS_WARN_IF(aRv.Failed())) {
+            return;
+          }
+
           if (originIsHttps) {
-            return NS_ERROR_DOM_SECURITY_ERR;
+            aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
+            return;
           }
         }
       }
     }
   }
 
   // Assign the sub protocol list and scan it for illegal values
   for (uint32_t index = 0; index < aProtocolArray.Length(); ++index) {
     for (uint32_t i = 0; i < aProtocolArray[index].Length(); ++i) {
       if (aProtocolArray[index][i] < static_cast<char16_t>(0x0021) ||
-          aProtocolArray[index][i] > static_cast<char16_t>(0x007E))
-        return NS_ERROR_DOM_SYNTAX_ERR;
+          aProtocolArray[index][i] > static_cast<char16_t>(0x007E)) {
+        aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
+        return;
+      }
     }
 
     if (!mRequestedProtocolList.IsEmpty()) {
       mRequestedProtocolList.AppendLiteral(", ");
     }
 
     AppendUTF16toUTF8(aProtocolArray[index], mRequestedProtocolList);
   }
 
+  nsCOMPtr<nsIURI> uri;
+  {
+    nsresult rv = NS_NewURI(getter_AddRefs(uri), mURI);
+
+    // We crash here because we are sure that mURI is a valid URI, so either we
+    // are OOM'ing or something else bad is happening.
+    if (NS_FAILED(rv)) {
+      MOZ_CRASH();
+    }
+  }
+
   // Check content policy.
   int16_t shouldLoad = nsIContentPolicy::ACCEPT;
   nsCOMPtr<nsIDocument> originDoc = nsContentUtils::GetDocumentFromScriptContext(sc);
   mOriginDocument = do_GetWeakReference(originDoc);
-  rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_WEBSOCKET,
-                                 mURI,
-                                 mPrincipal,
-                                 originDoc,
-                                 EmptyCString(),
-                                 nullptr,
-                                 &shouldLoad,
-                                 nsContentUtils::GetContentPolicy(),
-                                 nsContentUtils::GetSecurityManager());
-  NS_ENSURE_SUCCESS(rv, rv);
+  aRv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_WEBSOCKET,
+                                  uri,
+                                  mPrincipal,
+                                  originDoc,
+                                  EmptyCString(),
+                                  nullptr,
+                                  &shouldLoad,
+                                  nsContentUtils::GetContentPolicy(),
+                                  nsContentUtils::GetSecurityManager());
+  if (NS_WARN_IF(aRv.Failed())) {
+    return;
+  }
+
   if (NS_CP_REJECTED(shouldLoad)) {
     // Disallowed by content policy.
-    return NS_ERROR_CONTENT_BLOCKED;
+    aRv.Throw(NS_ERROR_CONTENT_BLOCKED);
+    return;
   }
 
   // the constructor should throw a SYNTAX_ERROR only if it fails to parse the
-  // url parameter, so don't throw if EstablishConnection fails, and call
+  // url parameter, so don't throw if InitializeConnection fails, and call
   // onerror/onclose asynchronously
-  if (NS_FAILED(EstablishConnection())) {
-    FailConnection(nsIWebSocketChannel::CLOSE_ABNORMAL);
+  if (NS_FAILED(InitializeConnection())) {
+    *aConnectionFailed = true;
+  } else {
+    *aConnectionFailed = false;
   }
-
-  return NS_OK;
+}
+
+void
+WebSocketImpl::AsyncOpen(ErrorResult& aRv)
+{
+  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+
+  nsCString asciiOrigin;
+  aRv = nsContentUtils::GetASCIIOrigin(mPrincipal, asciiOrigin);
+  if (NS_WARN_IF(aRv.Failed())) {
+    return;
+  }
+
+  ToLowerCase(asciiOrigin);
+
+  nsCOMPtr<nsIURI> uri;
+  aRv = NS_NewURI(getter_AddRefs(uri), mURI);
+  MOZ_ASSERT(!aRv.Failed());
+
+  aRv = mChannel->AsyncOpen(uri, asciiOrigin, this, nullptr);
+  if (NS_WARN_IF(aRv.Failed())) {
+    return;
+  }
 }
 
 //-----------------------------------------------------------------------------
-// WebSocket methods:
+// WebSocketImpl methods:
 //-----------------------------------------------------------------------------
 
-class nsAutoCloseWS
+class nsAutoCloseWS MOZ_FINAL
 {
 public:
-  explicit nsAutoCloseWS(WebSocket* aWebSocket)
-    : mWebSocket(aWebSocket)
+  explicit nsAutoCloseWS(WebSocketImpl* aWebSocketImpl)
+    : mWebSocketImpl(aWebSocketImpl)
   {}
 
   ~nsAutoCloseWS()
   {
-    if (!mWebSocket->mChannel) {
-      mWebSocket->CloseConnection(nsIWebSocketChannel::CLOSE_INTERNAL_ERROR);
+    if (!mWebSocketImpl->mChannel) {
+      mWebSocketImpl->CloseConnection(nsIWebSocketChannel::CLOSE_INTERNAL_ERROR);
     }
   }
 private:
-  nsRefPtr<WebSocket> mWebSocket;
+  nsRefPtr<WebSocketImpl> mWebSocketImpl;
 };
 
 nsresult
-WebSocket::EstablishConnection()
+WebSocketImpl::InitializeConnection()
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  AssertIsOnMainThread();
   NS_ABORT_IF_FALSE(!mChannel, "mChannel should be null");
 
   nsCOMPtr<nsIWebSocketChannel> wsChannel;
   nsAutoCloseWS autoClose(this);
   nsresult rv;
 
   if (mSecure) {
     wsChannel =
       do_CreateInstance("@mozilla.org/network/protocol;1?name=wss", &rv);
   } else {
     wsChannel =
       do_CreateInstance("@mozilla.org/network/protocol;1?name=ws", &rv);
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = wsChannel->SetNotificationCallbacks(this);
-  NS_ENSURE_SUCCESS(rv, rv);
-
   // add ourselves to the document's load group and
   // provide the http stack the loadgroup info too
   nsCOMPtr<nsILoadGroup> loadGroup;
   rv = GetLoadGroup(getter_AddRefs(loadGroup));
   if (loadGroup) {
     rv = wsChannel->SetLoadGroup(loadGroup);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = loadGroup->AddRequest(this, nullptr);
@@ -813,57 +1471,58 @@ WebSocket::EstablishConnection()
   rv = wsChannel->SetLoadInfo(loadInfo);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!mRequestedProtocolList.IsEmpty()) {
     rv = wsChannel->SetProtocol(mRequestedProtocolList);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  nsCString asciiOrigin;
-  rv = nsContentUtils::GetASCIIOrigin(mPrincipal, asciiOrigin);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  ToLowerCase(asciiOrigin);
-
-  rv = wsChannel->AsyncOpen(mURI, asciiOrigin, this, nullptr);
+  nsCOMPtr<nsIThreadRetargetableRequest> rr = do_QueryInterface(wsChannel);
+  NS_ENSURE_TRUE(rr, NS_ERROR_FAILURE);
+
+  rv = rr->RetargetDeliveryTo(this);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mChannel = wsChannel;
 
   return NS_OK;
 }
 
 void
-WebSocket::DispatchConnectionCloseEvents()
+WebSocketImpl::DispatchConnectionCloseEvents()
 {
-  mReadyState = WebSocket::CLOSED;
+  AssertIsOnTargetThread();
+  SetReadyState(WebSocket::CLOSED);
 
   // Call 'onerror' if needed
   if (mFailed) {
-    nsresult rv = CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("error"));
+    nsresult rv =
+      mWebSocket->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("error"));
     if (NS_FAILED(rv)) {
       NS_WARNING("Failed to dispatch the error event");
     }
   }
 
-  nsresult rv = CreateAndDispatchCloseEvent(mCloseEventWasClean, mCloseEventCode,
-                                            mCloseEventReason);
+  nsresult rv = mWebSocket->CreateAndDispatchCloseEvent(mCloseEventWasClean,
+                                                        mCloseEventCode,
+                                                        mCloseEventReason);
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to dispatch the close event");
   }
 
-  UpdateMustKeepAlive();
+  mWebSocket->UpdateMustKeepAlive();
   Disconnect();
 }
 
 nsresult
-WebSocket::CreateAndDispatchSimpleEvent(const nsString& aName)
+WebSocket::CreateAndDispatchSimpleEvent(const nsAString& aName)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  MOZ_ASSERT(mImpl);
+  mImpl->AssertIsOnTargetThread();
 
   nsresult rv = CheckInnerWindowCorrectness();
   if (NS_FAILED(rv)) {
     return NS_OK;
   }
 
   nsCOMPtr<nsIDOMEvent> event;
   rv = NS_NewDOMEvent(getter_AddRefs(event), this, nullptr, nullptr);
@@ -875,81 +1534,104 @@ WebSocket::CreateAndDispatchSimpleEvent(
 
   event->SetTrusted(true);
 
   return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
 }
 
 nsresult
 WebSocket::CreateAndDispatchMessageEvent(const nsACString& aData,
-                                         bool isBinary)
+                                         bool aIsBinary)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-
-  nsresult rv = CheckInnerWindowCorrectness();
-  if (NS_FAILED(rv))
-    return NS_OK;
+  MOZ_ASSERT(mImpl);
+  mImpl->AssertIsOnTargetThread();
 
   AutoJSAPI jsapi;
-  if (NS_WARN_IF(!jsapi.Init(GetOwner()))) {
-    return NS_ERROR_FAILURE;
+
+  if (NS_IsMainThread()) {
+    if (NS_WARN_IF(!jsapi.Init(GetOwner()))) {
+      return NS_ERROR_FAILURE;
+    }
+  } else {
+    MOZ_ASSERT(mWorkerPrivate);
+    if (NS_WARN_IF(!jsapi.Init(mWorkerPrivate->GlobalScope()))) {
+      return NS_ERROR_FAILURE;
+    }
   }
-  JSContext* cx = jsapi.cx();
+
+  return CreateAndDispatchMessageEvent(jsapi.cx(), aData, aIsBinary);
+}
+
+nsresult
+WebSocket::CreateAndDispatchMessageEvent(JSContext* aCx,
+                                         const nsACString& aData,
+                                         bool aIsBinary)
+{
+  MOZ_ASSERT(mImpl);
+  mImpl->AssertIsOnTargetThread();
+
+  nsresult rv = CheckInnerWindowCorrectness();
+  if (NS_FAILED(rv)) {
+    return NS_OK;
+  }
 
   // Create appropriate JS object for message
-  JS::Rooted<JS::Value> jsData(cx);
-  if (isBinary) {
-    if (mBinaryType == dom::BinaryType::Blob) {
-      rv = nsContentUtils::CreateBlobBuffer(cx, GetOwner(), aData, &jsData);
+  JS::Rooted<JS::Value> jsData(aCx);
+  if (aIsBinary) {
+    if (mImpl->mBinaryType == dom::BinaryType::Blob) {
+      nsresult rv = nsContentUtils::CreateBlobBuffer(aCx, GetOwner(), aData,
+                                                     &jsData);
       NS_ENSURE_SUCCESS(rv, rv);
-    } else if (mBinaryType == dom::BinaryType::Arraybuffer) {
-      JS::Rooted<JSObject*> arrayBuf(cx);
-      rv = nsContentUtils::CreateArrayBuffer(cx, aData, arrayBuf.address());
+    } else if (mImpl->mBinaryType == dom::BinaryType::Arraybuffer) {
+      JS::Rooted<JSObject*> arrayBuf(aCx);
+      nsresult rv = nsContentUtils::CreateArrayBuffer(aCx, aData,
+                                                      arrayBuf.address());
       NS_ENSURE_SUCCESS(rv, rv);
       jsData = OBJECT_TO_JSVAL(arrayBuf);
     } else {
       NS_RUNTIMEABORT("Unknown binary type!");
       return NS_ERROR_UNEXPECTED;
     }
   } else {
     // JS string
     NS_ConvertUTF8toUTF16 utf16Data(aData);
     JSString* jsString;
-    jsString = JS_NewUCStringCopyN(cx, utf16Data.get(), utf16Data.Length());
+    jsString = JS_NewUCStringCopyN(aCx, utf16Data.get(), utf16Data.Length());
     NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
 
     jsData = STRING_TO_JSVAL(jsString);
   }
 
   // create an event that uses the MessageEvent interface,
   // which does not bubble, is not cancelable, and has no default action
 
   nsCOMPtr<nsIDOMEvent> event;
   rv = NS_NewDOMMessageEvent(getter_AddRefs(event), this, nullptr, nullptr);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDOMMessageEvent> messageEvent = do_QueryInterface(event);
   rv = messageEvent->InitMessageEvent(NS_LITERAL_STRING("message"),
                                       false, false,
                                       jsData,
-                                      mUTF16Origin,
+                                      mImpl->mUTF16Origin,
                                       EmptyString(), nullptr);
   NS_ENSURE_SUCCESS(rv, rv);
 
   event->SetTrusted(true);
 
   return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
 }
 
 nsresult
 WebSocket::CreateAndDispatchCloseEvent(bool aWasClean,
                                        uint16_t aCode,
-                                       const nsString &aReason)
+                                       const nsAString &aReason)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  MOZ_ASSERT(mImpl);
+  mImpl->AssertIsOnTargetThread();
 
   nsresult rv = CheckInnerWindowCorrectness();
   if (NS_FAILED(rv)) {
     return NS_OK;
   }
 
   CloseEventInit init;
   init.mBubbles = false;
@@ -960,25 +1642,66 @@ WebSocket::CreateAndDispatchCloseEvent(b
 
   nsRefPtr<CloseEvent> event =
     CloseEvent::Constructor(this, NS_LITERAL_STRING("close"), init);
   event->SetTrusted(true);
 
   return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
 }
 
+namespace {
+
+class PrefEnabledRunnable MOZ_FINAL : public WorkerMainThreadRunnable
+{
+public:
+  PrefEnabledRunnable(WorkerPrivate* aWorkerPrivate)
+    : WorkerMainThreadRunnable(aWorkerPrivate)
+    , mEnabled(false)
+  { }
+
+  bool MainThreadRun() MOZ_OVERRIDE
+  {
+    AssertIsOnMainThread();
+    mEnabled = WebSocket::PrefEnabled(nullptr, nullptr);
+    return true;
+  }
+
+  bool IsEnabled() const
+  {
+    return mEnabled;
+  }
+
+private:
+  bool mEnabled;
+};
+
+} // anonymous namespace
+
 bool
-WebSocket::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
+WebSocket::PrefEnabled(JSContext* /* aCx */, JSObject* /* aGlobal */)
 {
-  return Preferences::GetBool("network.websocket.enabled", true);
+  if (NS_IsMainThread()) {
+    return Preferences::GetBool("network.websocket.enabled", true);
+  } else {
+    WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+    MOZ_ASSERT(workerPrivate);
+    workerPrivate->AssertIsOnWorkerThread();
+
+    nsRefPtr<PrefEnabledRunnable> runnable =
+      new PrefEnabledRunnable(workerPrivate);
+    runnable->Dispatch(workerPrivate->GetJSContext());
+
+    return runnable->IsEnabled();
+  }
 }
 
 nsresult
-WebSocket::ParseURL(const nsString& aURL)
+WebSocketImpl::ParseURL(const nsAString& aURL)
 {
+  AssertIsOnMainThread();
   NS_ENSURE_TRUE(!aURL.IsEmpty(), NS_ERROR_DOM_SYNTAX_ERR);
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR);
 
   nsCOMPtr<nsIURL> parsedURL = do_QueryInterface(uri, &rv);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR);
@@ -1041,39 +1764,44 @@ WebSocket::ParseURL(const nsString& aURL
   for (i = 0; i < length; ++i) {
     if (mResource[i] < static_cast<char16_t>(0x0021) ||
         mResource[i] > static_cast<char16_t>(0x007E)) {
       return NS_ERROR_DOM_SYNTAX_ERR;
     }
   }
 
   mOriginalURL = aURL;
-  mURI = parsedURL;
+
+  rv = parsedURL->GetSpec(mURI);
+  MOZ_ASSERT(NS_SUCCEEDED(rv));
+
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // Methods that keep alive the WebSocket object when:
 //   1. the object has registered event listeners that can be triggered
 //      ("strong event listeners");
 //   2. there are outgoing not sent messages.
 //-----------------------------------------------------------------------------
 
 void
 WebSocket::UpdateMustKeepAlive()
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-  if (!mCheckMustKeepAlive) {
+  // Here we could not have mImpl.
+  MOZ_ASSERT(NS_IsMainThread() == !mWorkerPrivate);
+
+  if (!mCheckMustKeepAlive || !mImpl) {
     return;
   }
 
   bool shouldKeepAlive = false;
 
   if (mListenerManager) {
-    switch (mReadyState)
+    switch (mImpl->ReadyState())
     {
       case WebSocket::CONNECTING:
       {
         if (mListenerManager->HasListenersFor(nsGkAtoms::onopen) ||
             mListenerManager->HasListenersFor(nsGkAtoms::onmessage) ||
             mListenerManager->HasListenersFor(nsGkAtoms::onerror) ||
             mListenerManager->HasListenersFor(nsGkAtoms::onclose)) {
           shouldKeepAlive = true;
@@ -1082,127 +1810,241 @@ WebSocket::UpdateMustKeepAlive()
       break;
 
       case WebSocket::OPEN:
       case WebSocket::CLOSING:
       {
         if (mListenerManager->HasListenersFor(nsGkAtoms::onmessage) ||
             mListenerManager->HasListenersFor(nsGkAtoms::onerror) ||
             mListenerManager->HasListenersFor(nsGkAtoms::onclose) ||
-            mOutgoingBufferedAmount != 0) {
+            mImpl->mOutgoingBufferedAmount != 0) {
           shouldKeepAlive = true;
         }
       }
       break;
 
       case WebSocket::CLOSED:
       {
         shouldKeepAlive = false;
       }
     }
   }
 
   if (mKeepingAlive && !shouldKeepAlive) {
     mKeepingAlive = false;
-    static_cast<EventTarget*>(this)->Release();
+    mImpl->ReleaseObject();
   } else if (!mKeepingAlive && shouldKeepAlive) {
     mKeepingAlive = true;
-    static_cast<EventTarget*>(this)->AddRef();
+    mImpl->AddRefObject();
   }
 }
 
 void
 WebSocket::DontKeepAliveAnyMore()
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  // Here we could not have mImpl.
+  MOZ_ASSERT(NS_IsMainThread() == !mWorkerPrivate);
+
   if (mKeepingAlive) {
+    MOZ_ASSERT(mImpl);
+
     mKeepingAlive = false;
-    static_cast<EventTarget*>(this)->Release();
+    mImpl->ReleaseObject();
+  }
+
+  mCheckMustKeepAlive = false;
+}
+
+namespace {
+
+class WebSocketWorkerFeature MOZ_FINAL : public WorkerFeature
+{
+public:
+  explicit WebSocketWorkerFeature(WebSocketImpl* aWebSocketImpl)
+    : mWebSocketImpl(aWebSocketImpl)
+  {
+  }
+
+  bool Notify(JSContext* aCx, Status aStatus) MOZ_OVERRIDE
+  {
+    MOZ_ASSERT(aStatus > workers::Running);
+
+    if (aStatus >= Canceling) {
+      mWebSocketImpl->CloseConnection(nsIWebSocketChannel::CLOSE_GOING_AWAY);
+      mWebSocketImpl->UnregisterFeature();
+    }
+
+    return true;
+  }
+
+  bool Suspend(JSContext* aCx)
+  {
+    mWebSocketImpl->CloseConnection(nsIWebSocketChannel::CLOSE_GOING_AWAY);
+    mWebSocketImpl->UnregisterFeature();
+    return true;
   }
-  mCheckMustKeepAlive = false;
+
+private:
+  WebSocketImpl* mWebSocketImpl;
+};
+
+} // anonymous namespace
+
+void
+WebSocketImpl::AddRefObject()
+{
+  AssertIsOnTargetThread();
+  AddRef();
+
+  if (mWorkerPrivate && !mWorkerFeature) {
+    mWorkerPrivate->AssertIsOnWorkerThread();
+    MOZ_ASSERT(!mWorkerFeature);
+    mWorkerFeature = new WebSocketWorkerFeature(this);
+
+    JSContext* cx = GetCurrentThreadJSContext();
+    if (!mWorkerPrivate->AddFeature(cx, mWorkerFeature)) {
+      NS_WARNING("Failed to register a feature.");
+      mWorkerFeature = nullptr;
+    }
+  }
+}
+
+void
+WebSocketImpl::ReleaseObject()
+{
+  AssertIsOnTargetThread();
+
+  if (mWorkerPrivate && !mWorkerFeature) {
+    UnregisterFeature();
+  }
+
+  Release();
+}
+
+void
+WebSocketImpl::UnregisterFeature()
+{
+  MOZ_ASSERT(mWorkerPrivate);
+  mWorkerPrivate->AssertIsOnWorkerThread();
+  MOZ_ASSERT(mWorkerFeature);
+
+  JSContext* cx = GetCurrentThreadJSContext();
+  mWorkerPrivate->RemoveFeature(cx, mWorkerFeature);
+  mWorkerFeature = nullptr;
 }
 
 nsresult
-WebSocket::UpdateURI()
+WebSocketImpl::UpdateURI()
 {
+  AssertIsOnTargetThread();
+
   // Check for Redirections
-  nsCOMPtr<nsIURI> uri;
-  nsresult rv = mChannel->GetURI(getter_AddRefs(uri));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsAutoCString spec;
-  rv = uri->GetSpec(spec);
-  NS_ENSURE_SUCCESS(rv, rv);
-  CopyUTF8toUTF16(spec, mEffectiveURL);
-
-  bool isWSS = false;
-  rv = uri->SchemeIs("wss", &isWSS);
-  NS_ENSURE_SUCCESS(rv, rv);
-  mSecure = isWSS ? true : false;
+  nsRefPtr<BaseWebSocketChannel> channel;
+  channel = static_cast<BaseWebSocketChannel*>(mChannel.get());
+  MOZ_ASSERT(channel);
+
+  channel->GetEffectiveURL(mEffectiveURL);
+  mSecure = channel->IsEncrypted();
 
   return NS_OK;
 }
 
 void
 WebSocket::EventListenerAdded(nsIAtom* aType)
 {
+  AssertIsOnMainThread();
   UpdateMustKeepAlive();
 }
 
 void
 WebSocket::EventListenerRemoved(nsIAtom* aType)
 {
+  AssertIsOnMainThread();
   UpdateMustKeepAlive();
 }
 
 //-----------------------------------------------------------------------------
 // WebSocket - methods
 //-----------------------------------------------------------------------------
 
+// webIDL: readonly attribute unsigned short readyState;
+uint16_t
+WebSocket::ReadyState() const
+{
+  MOZ_ASSERT(mImpl);
+  return mImpl->ReadyState();
+}
+
+// webIDL: readonly attribute unsigned long bufferedAmount;
+uint32_t
+WebSocket::BufferedAmount() const
+{
+  MOZ_ASSERT(mImpl);
+  return mImpl->BufferedAmount();
+}
+
+// webIDL: attribute BinaryType binaryType;
+dom::BinaryType
+WebSocket::BinaryType() const
+{
+  MOZ_ASSERT(mImpl);
+  return mImpl->BinaryType();
+}
+
+// webIDL: attribute BinaryType binaryType;
+void
+WebSocket::SetBinaryType(dom::BinaryType aData)
+{
+  MOZ_ASSERT(mImpl);
+  mImpl->SetBinaryType(aData);
+}
+
 // webIDL: readonly attribute DOMString url
 void
 WebSocket::GetUrl(nsAString& aURL)
 {
-  if (mEffectiveURL.IsEmpty()) {
-    aURL = mOriginalURL;
-  } else {
-    aURL = mEffectiveURL;
-  }
+  MOZ_ASSERT(mImpl);
+  mImpl->GetUrl(aURL);
 }
 
 // webIDL: readonly attribute DOMString extensions;
 void
 WebSocket::GetExtensions(nsAString& aExtensions)
 {
-  CopyUTF8toUTF16(mEstablishedExtensions, aExtensions);
+  MOZ_ASSERT(mImpl);
+  mImpl->AssertIsOnTargetThread();
+
+  CopyUTF8toUTF16(mImpl->mEstablishedExtensions, aExtensions);
 }
 
 // webIDL: readonly attribute DOMString protocol;
 void
 WebSocket::GetProtocol(nsAString& aProtocol)
 {
-  CopyUTF8toUTF16(mEstablishedProtocol, aProtocol);
+  MOZ_ASSERT(mImpl);
+  mImpl->AssertIsOnTargetThread();
+
+  CopyUTF8toUTF16(mImpl->mEstablishedProtocol, aProtocol);
 }
 
 // webIDL: void send(DOMString data);
 void
 WebSocket::Send(const nsAString& aData,
                 ErrorResult& aRv)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  MOZ_ASSERT(mImpl);
+  mImpl->AssertIsOnTargetThread();
 
   NS_ConvertUTF16toUTF8 msgString(aData);
-  Send(nullptr, msgString, msgString.Length(), false, aRv);
+  mImpl->Send(nullptr, msgString, msgString.Length(), false, aRv);
 }
 
 void
 WebSocket::Send(File& aData, ErrorResult& aRv)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-
   nsCOMPtr<nsIInputStream> msgStream;
   nsresult rv = aData.GetInternalStream(getter_AddRefs(msgStream));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return;
   }
 
   uint64_t msgLength;
@@ -1212,74 +2054,79 @@ WebSocket::Send(File& aData, ErrorResult
     return;
   }
 
   if (msgLength > UINT32_MAX) {
     aRv.Throw(NS_ERROR_FILE_TOO_BIG);
     return;
   }
 
-  Send(msgStream, EmptyCString(), msgLength, true, aRv);
+  mImpl->Send(msgStream, EmptyCString(), msgLength, true, aRv);
 }
 
 void
 WebSocket::Send(const ArrayBuffer& aData,
                 ErrorResult& aRv)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  MOZ_ASSERT(mImpl);
+  mImpl->AssertIsOnTargetThread();
 
   aData.ComputeLengthAndData();
 
   static_assert(sizeof(*aData.Data()) == 1, "byte-sized data required");
 
   uint32_t len = aData.Length();
   char* data = reinterpret_cast<char*>(aData.Data());
 
   nsDependentCSubstring msgString(data, len);
-  Send(nullptr, msgString, len, true, aRv);
+  mImpl->Send(nullptr, msgString, len, true, aRv);
 }
 
 void
 WebSocket::Send(const ArrayBufferView& aData,
                 ErrorResult& aRv)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  MOZ_ASSERT(mImpl);
+  mImpl->AssertIsOnTargetThread();
 
   aData.ComputeLengthAndData();
 
   static_assert(sizeof(*aData.Data()) == 1, "byte-sized data required");
 
   uint32_t len = aData.Length();
   char* data = reinterpret_cast<char*>(aData.Data());
 
   nsDependentCSubstring msgString(data, len);
-  Send(nullptr, msgString, len, true, aRv);
+  mImpl->Send(nullptr, msgString, len, true, aRv);
 }
 
 void
-WebSocket::Send(nsIInputStream* aMsgStream,
-                const nsACString& aMsgString,
-                uint32_t aMsgLength,
-                bool aIsBinary,
-                ErrorResult& aRv)
+WebSocketImpl::Send(nsIInputStream* aMsgStream,
+                    const nsACString& aMsgString,
+                    uint32_t aMsgLength,
+                    bool aIsBinary,
+                    ErrorResult& aRv)
 {
-  if (mReadyState == WebSocket::CONNECTING) {
+  AssertIsOnTargetThread();
+
+  int64_t readyState = ReadyState();
+  if (readyState == WebSocket::CONNECTING) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   // Always increment outgoing buffer len, even if closed
   mOutgoingBufferedAmount += aMsgLength;
 
-  if (mReadyState == WebSocket::CLOSING ||
-      mReadyState == WebSocket::CLOSED) {
+  if (readyState == WebSocket::CLOSING ||
+      readyState == WebSocket::CLOSED) {
     return;
   }
 
-  MOZ_ASSERT(mReadyState == WebSocket::OPEN,
+  MOZ_ASSERT(readyState == WebSocket::OPEN,
              "Unknown state in WebSocket::Send");
 
   nsresult rv;
   if (aMsgStream) {
     rv = mChannel->SendBinaryStream(aMsgStream, aMsgLength);
   } else {
     if (aIsBinary) {
       rv = mChannel->SendBinaryMsg(aMsgString);
@@ -1288,26 +2135,35 @@ WebSocket::Send(nsIInputStream* aMsgStre
     }
   }
 
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return;
   }
 
-  UpdateMustKeepAlive();
+  mWebSocket->UpdateMustKeepAlive();
 }
 
 // webIDL: void close(optional unsigned short code, optional DOMString reason):
 void
 WebSocket::Close(const Optional<uint16_t>& aCode,
                  const Optional<nsAString>& aReason,
                  ErrorResult& aRv)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  MOZ_ASSERT(mImpl);
+  mImpl->Close(aCode, aReason, aRv);
+}
+
+void
+WebSocketImpl::Close(const Optional<uint16_t>& aCode,
+                     const Optional<nsAString>& aReason,
+                     ErrorResult& aRv)
+{
+  AssertIsOnTargetThread();
 
   // the reason code is optional, but if provided it must be in a specific range
   uint16_t closeCode = 0;
   if (aCode.WasPassed()) {
     if (aCode.Value() != 1000 && (aCode.Value() < 3000 || aCode.Value() > 4999)) {
       aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
       return;
     }
@@ -1320,141 +2176,314 @@ WebSocket::Close(const Optional<uint16_t
 
     // The API requires the UTF-8 string to be 123 or less bytes
     if (closeReason.Length() > 123) {
       aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
       return;
     }
   }
 
-  if (mReadyState == WebSocket::CLOSING ||
-      mReadyState == WebSocket::CLOSED) {
+  int64_t readyState = ReadyState();
+  if (readyState == WebSocket::CLOSING ||
+      readyState == WebSocket::CLOSED) {
     return;
   }
 
-  if (mReadyState == WebSocket::CONNECTING) {
+  if (readyState == WebSocket::CONNECTING) {
     FailConnection(closeCode, closeReason);
     return;
   }
 
-  MOZ_ASSERT(mReadyState == WebSocket::OPEN);
+  MOZ_ASSERT(readyState == WebSocket::OPEN);
   CloseConnection(closeCode, closeReason);
 }
 
 //-----------------------------------------------------------------------------
-// WebSocket::nsIObserver
+// WebSocketImpl::nsIObserver
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
-WebSocket::Observe(nsISupports* aSubject,
-                   const char* aTopic,
-                   const char16_t* aData)
+WebSocketImpl::Observe(nsISupports* aSubject,
+                       const char* aTopic,
+                       const char16_t* aData)
 {
-  if ((mReadyState == WebSocket::CLOSING) ||
-      (mReadyState == WebSocket::CLOSED)) {
+  AssertIsOnMainThread();
+
+  int64_t readyState = ReadyState();
+  if ((readyState == WebSocket::CLOSING) ||
+      (readyState == WebSocket::CLOSED)) {
     return NS_OK;
   }
 
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aSubject);
-  if (!GetOwner() || window != GetOwner()) {
+  if (!mWebSocket->GetOwner() || window != mWebSocket->GetOwner()) {
     return NS_OK;
   }
 
   if ((strcmp(aTopic, DOM_WINDOW_FROZEN_TOPIC) == 0) ||
       (strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC) == 0))
   {
     CloseConnection(nsIWebSocketChannel::CLOSE_GOING_AWAY);
   }
 
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
-// WebSocket::nsIRequest
+// WebSocketImpl::nsIRequest
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
-WebSocket::GetName(nsACString& aName)
+WebSocketImpl::GetName(nsACString& aName)
 {
+  AssertIsOnMainThread();
+
   CopyUTF16toUTF8(mOriginalURL, aName);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-WebSocket::IsPending(bool* aValue)
+WebSocketImpl::IsPending(bool* aValue)
 {
-  *aValue = (mReadyState != WebSocket::CLOSED);
+  AssertIsOnTargetThread();
+
+  int64_t readyState = ReadyState();
+  *aValue = (readyState != WebSocket::CLOSED);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-WebSocket::GetStatus(nsresult* aStatus)
+WebSocketImpl::GetStatus(nsresult* aStatus)
 {
+  AssertIsOnTargetThread();
+
   *aStatus = NS_OK;
   return NS_OK;
 }
 
+namespace {
+
+class CancelRunnable MOZ_FINAL : public WorkerRunnable
+{
+public:
+  CancelRunnable(WorkerPrivate* aWorkerPrivate, WebSocketImpl* aImpl)
+    : WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
+    , mImpl(aImpl)
+  {
+  }
+
+  bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
+  {
+    aWorkerPrivate->AssertIsOnWorkerThread();
+    aWorkerPrivate->ModifyBusyCountFromWorker(aCx, true);
+    return !NS_FAILED(mImpl->CancelInternal());
+  }
+
+  void PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate, bool aRunResult)
+  {
+    aWorkerPrivate->ModifyBusyCountFromWorker(aCx, false);
+  }
+
+  bool
+  PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
+  {
+    return true;
+  }
+
+  void
+  PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
+               bool aDispatchResult)
+  {
+  }
+
+private:
+  nsRefPtr<WebSocketImpl> mImpl;
+};
+
+} // anonymous namespace
+
 // Window closed, stop/reload button pressed, user navigated away from page, etc.
 NS_IMETHODIMP
-WebSocket::Cancel(nsresult aStatus)
+WebSocketImpl::Cancel(nsresult aStatus)
 {
-  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
-
-  if (mReadyState == CLOSING || mReadyState == CLOSED) {
+  AssertIsOnMainThread();
+
+  if (mWorkerPrivate) {
+    nsRefPtr<CancelRunnable> runnable =
+      new CancelRunnable(mWorkerPrivate, this);
+    if (!runnable->Dispatch(nullptr)) {
+      return NS_ERROR_FAILURE;
+    }
+
+    return NS_OK;
+  }
+
+  return CancelInternal();
+}
+
+nsresult
+WebSocketImpl::CancelInternal()
+{
+  AssertIsOnTargetThread();
+
+  int64_t readyState = ReadyState();
+  if (readyState == WebSocket::CLOSING || readyState == WebSocket::CLOSED) {
     return NS_OK;
   }
 
   ConsoleError();
 
   return CloseConnection(nsIWebSocketChannel::CLOSE_GOING_AWAY);
 }
 
 NS_IMETHODIMP
-WebSocket::Suspend()
+WebSocketImpl::Suspend()
 {
+  AssertIsOnMainThread();
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+WebSocketImpl::Resume()
+{
+  AssertIsOnMainThread();
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-WebSocket::Resume()
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-WebSocket::GetLoadGroup(nsILoadGroup** aLoadGroup)
+WebSocketImpl::GetLoadGroup(nsILoadGroup** aLoadGroup)
 {
+  AssertIsOnMainThread();
+
   *aLoadGroup = nullptr;
 
-  nsresult rv;
-  nsIScriptContext* sc = GetContextForEventHandlers(&rv);
-  nsCOMPtr<nsIDocument> doc =
-    nsContentUtils::GetDocumentFromScriptContext(sc);
-
+  if (!mWorkerPrivate) {
+    nsresult rv;
+    nsIScriptContext* sc = mWebSocket->GetContextForEventHandlers(&rv);
+    nsCOMPtr<nsIDocument> doc =
+      nsContentUtils::GetDocumentFromScriptContext(sc);
+
+    if (doc) {
+      *aLoadGroup = doc->GetDocumentLoadGroup().take();
+    }
+
+    return NS_OK;
+  }
+
+  // Walk up to our containing page
+  WorkerPrivate* wp = mWorkerPrivate;
+  while (wp->GetParent()) {
+    wp = wp->GetParent();
+  }
+
+  nsPIDOMWindow* window = wp->GetWindow();
+  if (!window) {
+    return NS_OK;
+  }
+
+  nsIDocument* doc = window->GetExtantDoc();
   if (doc) {
     *aLoadGroup = doc->GetDocumentLoadGroup().take();
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-WebSocket::SetLoadGroup(nsILoadGroup* aLoadGroup)
+WebSocketImpl::SetLoadGroup(nsILoadGroup* aLoadGroup)
 {
+  AssertIsOnMainThread();
   return NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP
-WebSocket::GetLoadFlags(nsLoadFlags* aLoadFlags)
+WebSocketImpl::GetLoadFlags(nsLoadFlags* aLoadFlags)
 {
+  AssertIsOnMainThread();
+
   *aLoadFlags = nsIRequest::LOAD_BACKGROUND;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-WebSocket::SetLoadFlags(nsLoadFlags aLoadFlags)
+WebSocketImpl::SetLoadFlags(nsLoadFlags aLoadFlags)
 {
+  AssertIsOnMainThread();
+
   // we won't change the load flags at all.
   return NS_OK;
 }
 
+namespace {
+
+class WorkerRunnableDispatcher MOZ_FINAL : public WorkerRunnable
+{
+public:
+  WorkerRunnableDispatcher(WorkerPrivate* aWorkerPrivate, nsIRunnable* aEvent)
+    : WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
+    , mEvent(aEvent)
+  {
+  }
+
+  bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
+  {
+    aWorkerPrivate->AssertIsOnWorkerThread();
+    aWorkerPrivate->ModifyBusyCountFromWorker(aCx, true);
+    return !NS_FAILED(mEvent->Run());
+  }
+
+  void PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate, bool aRunResult)
+  {
+    aWorkerPrivate->ModifyBusyCountFromWorker(aCx, false);
+  }
+
+  bool
+  PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
+  {
+    return true;
+  }
+
+  void
+  PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
+               bool aDispatchResult)
+  {
+  }
+
+private:
+  nsCOMPtr<nsIRunnable> mEvent;
+};
+
+} // anonymous namespace
+
+NS_IMETHODIMP
+WebSocketImpl::Dispatch(nsIRunnable* aEvent, uint32_t aFlags)
+{
+  // If the target is the main-thread we can just dispatch the runnable.
+  if (!mWorkerPrivate) {
+    return NS_DispatchToMainThread(aEvent);
+  }
+
+  // If the target is a worker, we have to use a custom WorkerRunnableDispatcher
+  // runnable.
+  nsRefPtr<WorkerRunnableDispatcher> event =
+    new WorkerRunnableDispatcher(mWorkerPrivate, aEvent);
+  if (!event->Dispatch(nullptr)) {
+    return NS_ERROR_FAILURE;
+  }
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+WebSocketImpl::IsOnCurrentThread(bool* aResult)
+{
+  *aResult = IsTargetThread();
+  return NS_OK;
+}
+
+bool
+WebSocketImpl::IsTargetThread() const
+{
+  return NS_IsMainThread() == !mWorkerPrivate;
+}
+
 } // dom namespace
 } // mozilla namespace
--- a/content/base/src/WebSocket.h
+++ b/content/base/src/WebSocket.h
@@ -10,72 +10,62 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/TypedArray.h"
 #include "mozilla/dom/WebSocketBinding.h" // for BinaryType
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/ErrorResult.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
-#include "nsIInterfaceRequestor.h"
-#include "nsIObserver.h"
-#include "nsIRequest.h"
 #include "nsISupports.h"
 #include "nsISupportsUtils.h"
-#include "nsIWebSocketChannel.h"
-#include "nsIWebSocketListener.h"
 #include "nsString.h"
-#include "nsWeakReference.h"
 #include "nsWrapperCache.h"
 
 #define DEFAULT_WS_SCHEME_PORT  80
 #define DEFAULT_WSS_SCHEME_PORT 443
 
 namespace mozilla {
 namespace dom {
 
+namespace workers {
+class WorkerPrivate;
+}
+
 class File;
 
-class WebSocket MOZ_FINAL : public DOMEventTargetHelper,
-                            public nsIInterfaceRequestor,
-                            public nsIWebSocketListener,
-                            public nsIObserver,
-                            public nsSupportsWeakReference,
-                            public nsIRequest
+class WebSocketImpl;
+
+class WebSocket MOZ_FINAL : public DOMEventTargetHelper
 {
-friend class CallDispatchConnectionCloseEvents;
-friend class nsAutoCloseWS;
+  friend class WebSocketImpl;
 
 public:
   enum {
     CONNECTING = 0,
     OPEN       = 1,
     CLOSING    = 2,
     CLOSED     = 3
   };
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_INHERITED(
     WebSocket, DOMEventTargetHelper)
-  NS_DECL_NSIINTERFACEREQUESTOR
-  NS_DECL_NSIWEBSOCKETLISTENER
-  NS_DECL_NSIOBSERVER
-  NS_DECL_NSIREQUEST
 
   // EventTarget
   virtual void EventListenerAdded(nsIAtom* aType) MOZ_OVERRIDE;
   virtual void EventListenerRemoved(nsIAtom* aType) MOZ_OVERRIDE;
 
   virtual void DisconnectFromOwner() MOZ_OVERRIDE;
 
   // nsWrapperCache
   nsPIDOMWindow* GetParentObject() { return GetOwner(); }
 
-  virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
+  virtual JSObject* WrapObject(JSContext* cx) MOZ_OVERRIDE;
 
 public: // static helpers:
 
   // Determine if preferences allow WebSocket
   static bool PrefEnabled(JSContext* aCx = nullptr, JSObject* aGlobal = nullptr);
 
 public: // WebIDL interface:
 
@@ -93,20 +83,20 @@ public: // WebIDL interface:
                                                  const nsAString& aUrl,
                                                  const Sequence<nsString>& aProtocols,
                                                  ErrorResult& rv);
 
   // webIDL: readonly attribute DOMString url
   void GetUrl(nsAString& aResult);
 
   // webIDL: readonly attribute unsigned short readyState;
-  uint16_t ReadyState() const { return mReadyState; }
+  uint16_t ReadyState() const;
 
   // webIDL: readonly attribute unsigned long bufferedAmount;
-  uint32_t BufferedAmount() const { return mOutgoingBufferedAmount; }
+  uint32_t BufferedAmount() const;
 
   // webIDL: attribute Function? onopen;
   IMPL_EVENT_HANDLER(open)
 
   // webIDL: attribute Function? onerror;
   IMPL_EVENT_HANDLER(error)
 
   // webIDL: attribute Function? onclose;
@@ -122,143 +112,64 @@ public: // WebIDL interface:
   void Close(const Optional<uint16_t>& aCode,
              const Optional<nsAString>& aReason,
              ErrorResult& aRv);
 
   // webIDL: attribute Function? onmessage;
   IMPL_EVENT_HANDLER(message)
 
   // webIDL: attribute DOMString binaryType;
-  dom::BinaryType BinaryType() const { return mBinaryType; }
-  void SetBinaryType(dom::BinaryType aData) { mBinaryType = aData; }
+  dom::BinaryType BinaryType() const;
+  void SetBinaryType(dom::BinaryType aData);
 
   // webIDL: void send(DOMString|Blob|ArrayBufferView data);
   void Send(const nsAString& aData,
             ErrorResult& aRv);
   void Send(File& aData,
             ErrorResult& aRv);
   void Send(const ArrayBuffer& aData,
             ErrorResult& aRv);
   void Send(const ArrayBufferView& aData,
             ErrorResult& aRv);
 
 private: // constructor && distructor
   explicit WebSocket(nsPIDOMWindow* aOwnerWindow);
   virtual ~WebSocket();
 
-protected:
-  nsresult Init(JSContext* aCx,
-                nsIPrincipal* aPrincipal,
-                const nsAString& aURL,
-                nsTArray<nsString>& aProtocolArray);
-
-  void Send(nsIInputStream* aMsgStream,
-            const nsACString& aMsgString,
-            uint32_t aMsgLength,
-            bool aIsBinary,
-            ErrorResult& aRv);
-
-  nsresult ParseURL(const nsString& aURL);
-  nsresult EstablishConnection();
-
-  // These methods when called can release the WebSocket object
-  void FailConnection(uint16_t reasonCode,
-                      const nsACString& aReasonString = EmptyCString());
-  nsresult CloseConnection(uint16_t reasonCode,
-                           const nsACString& aReasonString = EmptyCString());
-  nsresult Disconnect();
-
-  nsresult ConsoleError();
-  nsresult PrintErrorOnConsole(const char* aBundleURI,
-                               const char16_t* aError,
-                               const char16_t** aFormatStrings,
-                               uint32_t aFormatStringsLen);
-
-  nsresult DoOnMessageAvailable(const nsACString& aMsg,
-                                bool isBinary);
-
-  // ConnectionCloseEvents: 'error' event if needed, then 'close' event.
-  // - These must not be dispatched while we are still within an incoming call
-  //   from JS (ex: close()).  Set 'sync' to false in that case to dispatch in a
-  //   separate new event.
-  nsresult ScheduleConnectionCloseEvents(nsISupports* aContext,
-                                         nsresult aStatusCode,
-                                         bool sync);
-  // 2nd half of ScheduleConnectionCloseEvents, sometimes run in its own event.
-  void DispatchConnectionCloseEvents();
-
   // These methods actually do the dispatch for various events.
-  nsresult CreateAndDispatchSimpleEvent(const nsString& aName);
+  nsresult CreateAndDispatchSimpleEvent(const nsAString& aName);
   nsresult CreateAndDispatchMessageEvent(const nsACString& aData,
-                                         bool isBinary);
+                                         bool aIsBinary);
+  nsresult CreateAndDispatchMessageEvent(JSContext* aCx,
+                                         const nsACString& aData,
+                                         bool aIsBinary);
   nsresult CreateAndDispatchCloseEvent(bool aWasClean,
                                        uint16_t aCode,
-                                       const nsString& aReason);
+                                       const nsAString& aReason);
 
   // if there are "strong event listeners" (see comment in WebSocket.cpp) or
   // outgoing not sent messages then this method keeps the object alive
   // when js doesn't have strong references to it.
   void UpdateMustKeepAlive();
   // ATTENTION, when calling this method the object can be released
   // (and possibly collected).
   void DontKeepAliveAnyMore();
 
-  nsresult UpdateURI();
-
-protected: //data
-
-  nsCOMPtr<nsIWebSocketChannel> mChannel;
+private:
+  WebSocket(const WebSocket& x) MOZ_DELETE;   // prevent bad usage
+  WebSocket& operator=(const WebSocket& x) MOZ_DELETE;
 
-  // related to the WebSocket constructor steps
-  nsString mOriginalURL;
-  nsString mEffectiveURL;   // after redirects
-  bool mSecure; // if true it is using SSL and the wss scheme,
-                // otherwise it is using the ws scheme with no SSL
+  // Raw pointer because this WebSocketImpl is created, managed and destroyed by
+  // WebSocket.
+  WebSocketImpl* mImpl;
+
+  // This is used just to check in which thread this object is used when mImpl
+  // is null.
+  workers::WorkerPrivate* mWorkerPrivate;
 
   bool mKeepingAlive;
   bool mCheckMustKeepAlive;
-  bool mOnCloseScheduled;
-  bool mFailed;
-  bool mDisconnected;
-
-  // Set attributes of DOM 'onclose' message
-  bool      mCloseEventWasClean;
-  nsString  mCloseEventReason;
-  uint16_t  mCloseEventCode;
-
-  nsCString mAsciiHost;  // hostname
-  uint32_t  mPort;
-  nsCString mResource; // [filepath[?query]]
-  nsString  mUTF16Origin;
-
-  nsCOMPtr<nsIURI> mURI;
-  nsCString mRequestedProtocolList;
-  nsCString mEstablishedProtocol;
-  nsCString mEstablishedExtensions;
-
-  uint16_t mReadyState;
-
-  nsCOMPtr<nsIPrincipal> mPrincipal;
-  nsWeakPtr              mOriginDocument;
-
-  uint32_t mOutgoingBufferedAmount;
-
-  dom::BinaryType mBinaryType;
-
-  // Web Socket owner information:
-  // - the script file name, UTF8 encoded.
-  // - source code line number where the Web Socket object was constructed.
-  // - the ID of the inner window where the script lives. Note that this may not
-  //   be the same as the Web Socket owner window.
-  // These attributes are used for error reporting.
-  nsCString mScriptFile;
-  uint32_t mScriptLine;
-  uint64_t mInnerWindowID;
-
-private:
-  WebSocket(const WebSocket& x) MOZ_DELETE;   // prevent bad usage
-  WebSocket& operator=(const WebSocket& x) MOZ_DELETE;
 };
 
 } //namespace dom
 } //namespace mozilla
 
 #endif
--- a/content/base/src/moz.build
+++ b/content/base/src/moz.build
@@ -76,16 +76,17 @@ EXPORTS.mozilla.dom += [
     'ImportManager.h',
     'Link.h',
     'NodeIterator.h',
     'ResponsiveImageSelector.h',
     'ShadowRoot.h',
     'StyleSheetList.h',
     'Text.h',
     'TreeWalker.h',
+    'WebSocket.h',
 ]
 
 UNIFIED_SOURCES += [
     'Attr.cpp',
     'ChildIterator.cpp',
     'Comment.cpp',
     'DirectionalityUtils.cpp',
     'DocumentFragment.cpp',
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -67,20 +67,16 @@
 #include "nsIDOMEventTarget.h"
 
 // CSS related includes
 #include "nsCSSRules.h"
 #include "nsIDOMCSSRule.h"
 #include "nsAutoPtr.h"
 #include "nsMemory.h"
 
-// Tranformiix
-#include "nsIXSLTProcessor.h"
-#include "nsIXSLTProcessorPrivate.h"
-
 // includes needed for the prototype chain interfaces
 #include "nsIDOMCSSCharsetRule.h"
 #include "nsIDOMCSSImportRule.h"
 #include "nsIDOMCSSMediaRule.h"
 #include "nsIDOMCSSFontFaceRule.h"
 #include "nsIDOMCSSMozDocumentRule.h"
 #include "nsIDOMCSSSupportsRule.h"
 #include "nsIDOMMozCSSKeyframeRule.h"
@@ -278,19 +274,16 @@ static nsDOMClassInfoData sClassInfoData
 #endif
 
   NS_DEFINE_CLASSINFO_DATA(CSSMozDocumentRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(CSSSupportsRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
-  NS_DEFINE_CLASSINFO_DATA(XSLTProcessor, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
-
   NS_DEFINE_CLASSINFO_DATA(XPathNSResolver, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozSmsMessage, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozMmsMessage, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -331,46 +324,16 @@ static nsDOMClassInfoData sClassInfoData
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULButtonElement, nsDOMGenericSH,
                                       DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULCheckboxElement, nsDOMGenericSH,
                                       DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULPopupElement, nsDOMGenericSH,
                                       DOM_DEFAULT_SCRIPTABLE_FLAGS)
 };
 
-#define NS_DEFINE_CONTRACT_CTOR(_class, _contract_id)                           \
-  static nsresult                                                               \
-  _class##Ctor(nsISupports** aInstancePtrResult)                                \
-  {                                                                             \
-    nsresult rv = NS_OK;                                                        \
-    nsCOMPtr<nsISupports> native = do_CreateInstance(_contract_id, &rv);        \
-    native.forget(aInstancePtrResult);                                          \
-    return rv;                                                                  \
-  }
-
-NS_DEFINE_CONTRACT_CTOR(XSLTProcessor,
-                        "@mozilla.org/document-transformer;1?type=xslt")
-
-#undef NS_DEFINE_CONTRACT_CTOR
-
-struct nsConstructorFuncMapData
-{
-  int32_t mDOMClassInfoID;
-  nsDOMConstructorFunc mConstructorFunc;
-};
-
-#define NS_DEFINE_CONSTRUCTOR_FUNC_DATA(_class, _func)                        \
-  { eDOMClassInfo_##_class##_id, _func },
-
-static const nsConstructorFuncMapData kConstructorFuncMap[] =
-{
-  NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XSLTProcessor, XSLTProcessorCtor)
-};
-#undef NS_DEFINE_CONSTRUCTOR_FUNC_DATA
-
 nsIXPConnect *nsDOMClassInfo::sXPConnect = nullptr;
 bool nsDOMClassInfo::sIsInitialized = false;
 
 
 jsid nsDOMClassInfo::sConstructor_id     = JSID_VOID;
 jsid nsDOMClassInfo::sWrappedJSObject_id = JSID_VOID;
 
 static const JSClass *sObjectClass = nullptr;
@@ -769,21 +732,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_BEGIN(CSSMozDocumentRule, nsIDOMCSSMozDocumentRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMozDocumentRule)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(CSSSupportsRule, nsIDOMCSSSupportsRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSSupportsRule)
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(XSLTProcessor, nsIXSLTProcessor)
-    DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessor)
-    DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorPrivate)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(XPathNSResolver, nsIDOMXPathNSResolver)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathNSResolver)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozSmsMessage, nsIDOMMozSmsMessage)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsMessage)
   DOM_CLASSINFO_MAP_END
 
@@ -1432,22 +1390,16 @@ nsDOMClassInfo::ShutDown()
 
   NS_IF_RELEASE(sXPConnect);
   sIsInitialized = false;
 }
 
 static nsDOMConstructorFunc
 FindConstructorFunc(const nsDOMClassInfoData *aDOMClassInfoData)
 {
-  for (uint32_t i = 0; i < ArrayLength(kConstructorFuncMap); ++i) {
-    if (&sClassInfoData[kConstructorFuncMap[i].mDOMClassInfoID] ==
-        aDOMClassInfoData) {
-      return kConstructorFuncMap[i].mConstructorFunc;
-    }
-  }
   return nullptr;
 }
 
 static nsresult
 BaseStubConstructor(nsIWeakReference* aWeakOwner,
                     const nsGlobalNameStruct *name_struct, JSContext *cx,
                     JS::Handle<JSObject*> obj, const JS::CallArgs &args)
 {
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -32,19 +32,16 @@ DOMCI_CLASS(XULTreeBuilder)
 
 #ifdef MOZ_XUL
 DOMCI_CLASS(TreeColumn)
 #endif
 
 DOMCI_CLASS(CSSMozDocumentRule)
 DOMCI_CLASS(CSSSupportsRule)
 
-// XSLTProcessor
-DOMCI_CLASS(XSLTProcessor)
-
 // DOM Level 3 XPath objects
 DOMCI_CLASS(XPathNSResolver)
 
 DOMCI_CLASS(MozSmsMessage)
 DOMCI_CLASS(MozMmsMessage)
 DOMCI_CLASS(MozMobileMessageThread)
 
 // @font-face in CSS
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1435,20 +1435,16 @@ DOMInterfaces = {
 
 'WebrtcGlobalInformation': {
     'nativeType': 'mozilla::dom::WebrtcGlobalInformation',
     'headerFile': 'WebrtcGlobalInformation.h',
     'wrapperCache': False,
     'concrete': False,
 },
 
-'WebSocket': {
-    'headerFile': 'WebSocket.h',
-},
-
 'Window': {
     'nativeType': 'nsGlobalWindow',
     'binaryNames': {
         'postMessage': 'postMessageMoz',
     },
 },
 
 'WindowProxy': [
@@ -1528,16 +1524,20 @@ DOMInterfaces = {
     'wrapperCache': False
 },
 
 'XPathExpression': {
     'wrapperCache': False,
     'nativeOwnership': 'owned',
 },
 
+'XSLTProcessor': {
+    'nativeType': 'txMozillaXSLTProcessor',
+},
+
 'XULDocument': {
     'headerFile': 'XULDocument.h'
 },
 
 'XULElement': {
     'nativeType': 'nsXULElement',
 },
 
--- a/dom/bindings/test/test_sequence_detection.html
+++ b/dom/bindings/test/test_sequence_detection.html
@@ -10,29 +10,41 @@ https://bugzilla.mozilla.org/show_bug.cg
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
   /** Test for Bug 1066432 **/
   SimpleTest.waitForExplicitFinish();
   SpecialPowers.pushPrefEnv({set: [['dom.expose_test_interfaces', true]]}, function() {
     var testInterfaceJS = new TestInterfaceJS();
     ok(testInterfaceJS, "got a TestInterfaceJS object");
+
+    var nonIterableObject = { "@@iterator": 5 };
+    if (typeof Symbol === "function") {
+      // Make this test fail if Symbol.iterator is correctly implemented.
+      // This is here to make sure this test is updated when bug 918828 lands,
+      // at which point the correct code will be:
+      //   var JS_HAS_SYMBOLS = typeof Symbol === "function";
+      //   var std_iterator = JS_HAS_SYMBOLS ? Symbol.iterator : "@@iterator";
+      //   var nonIterableObject = { [std_iterator]: 5};
+      // Otherwise, fixing bug 918828 would cause this test to silently stop
+      // testing what it's supposed to be testing.
+      nonIterableObject[Symbol.iterator] = Array.prototype[Symbol.iterator];
+    }
+
     try {
-      testInterfaceJS.testSequenceOverload(
-        { "@@iterator": 5, [Symbol.iterator]: Array.prototype[Symbol.iterator] });
-      ok(false, "Should have thrown in the overload case");
+      testInterfaceJS.testSequenceOverload(nonIterableObject);
+      ok(false, "Should have thrown in the overload case");  // see long comment above!
     } catch (e) {
       ise(e.name, "TypeError", "Should get a TypeError for the overload case");
       ok(e.message.contains("not iterable"),
          "Should have a message about being non-iterable in the overload case");
     }
 
     try {
-      testInterfaceJS.testSequenceUnion(
-        { "@@iterator": 5, [Symbol.iterator]: Array.prototype[Symbol.iterator] });
+      testInterfaceJS.testSequenceUnion(nonIterableObject);
       ok(false, "Should have thrown in the union case");
     } catch (e) {
       ise(e.name, "TypeError", "Should get a TypeError for the union case");
       ok(e.message.contains("not iterable"),
          "Should have a message about being non-iterable in the union case");
     }
 
     SimpleTest.finish();
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -111,17 +111,16 @@
 #include "nsSVGLength2.h"
 #include "nsDeviceContext.h"
 #include "nsFontMetrics.h"
 
 #undef free // apparently defined by some windows header, clashing with a free()
             // method in SkTypes.h
 #ifdef USE_SKIA
 #include "SkiaGLGlue.h"
-#include "SurfaceStream.h"
 #include "SurfaceTypes.h"
 #endif
 
 using mozilla::gl::GLContext;
 using mozilla::gl::SkiaGLGlue;
 using mozilla::gl::GLContextProvider;
 
 #ifdef XP_WIN
@@ -706,17 +705,17 @@ public:
     }
   }
 
   static void PreTransactionCallback(void* aData)
   {
     CanvasRenderingContext2DUserData* self =
       static_cast<CanvasRenderingContext2DUserData*>(aData);
     CanvasRenderingContext2D* context = self->mContext;
-    if (!context || !context->mStream || !context->mTarget)
+    if (!context || !context->mTarget)
       return;
 
     // Since SkiaGL default to store drawing command until flush
     // We will have to flush it before present.
     context->mTarget->Flush();
   }
 
   static void DidTransactionCallback(void* aData)
@@ -821,17 +820,16 @@ DrawTarget* CanvasRenderingContext2D::sE
 
 CanvasRenderingContext2D::CanvasRenderingContext2D()
   : mRenderingMode(RenderingMode::OpenGLBackendMode)
   // these are the default values from the Canvas spec
   , mWidth(0), mHeight(0)
   , mZero(false), mOpaque(false)
   , mResetLayer(true)
   , mIPC(false)
-  , mStream(nullptr)
   , mIsEntireFrameInvalid(false)
   , mPredictManyRedrawCalls(false), mPathTransformWillUpdate(false)
   , mInvalidateCount(0)
 {
   sNumLivingContexts++;
 
   // The default is to use OpenGL mode
   if (!gfxPlatform::GetPlatform()->UseAcceleratedSkiaCanvas()) {
@@ -907,17 +905,16 @@ CanvasRenderingContext2D::Reset()
 
   // only do this for non-docshell created contexts,
   // since those are the ones that we created a surface for
   if (mTarget && IsTargetValid() && !mDocShell) {
     gCanvasAzureMemoryUsed -= mWidth * mHeight * 4;
   }
 
   mTarget = nullptr;
-  mStream = nullptr;
 
   // reset hit regions
   mHitRegionsOptions.ClearAndRetainStorage();
 
   // Since the target changes the backing texture will change, and this will
   // no longer be valid.
   mIsEntireFrameInvalid = false;
   mPredictManyRedrawCalls = false;
@@ -1020,18 +1017,20 @@ CanvasRenderingContext2D::Redraw(const m
   nsSVGEffects::InvalidateDirectRenderingObservers(mCanvasElement);
 
   mCanvasElement->InvalidateCanvasContent(&r);
 }
 
 void
 CanvasRenderingContext2D::DidRefresh()
 {
-  if (mStream && mStream->GLContext()) {
-    mStream->GLContext()->FlushIfHeavyGLCallsSinceLastFlush();
+  SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
+  if (glue) {
+    auto gl = glue->GetGLContext();
+    gl->FlushIfHeavyGLCallsSinceLastFlush();
   }
 }
 
 void
 CanvasRenderingContext2D::RedrawUser(const gfxRect& r)
 {
   if (mIsEntireFrameInvalid) {
     ++mInvalidateCount;
@@ -1047,17 +1046,16 @@ bool CanvasRenderingContext2D::SwitchRen
 {
   if (!IsTargetValid() || mRenderingMode == aRenderingMode) {
     return false;
   }
 
   RefPtr<SourceSurface> snapshot = mTarget->Snapshot();
   RefPtr<DrawTarget> oldTarget = mTarget;
   mTarget = nullptr;
-  mStream = nullptr;
   mResetLayer = true;
 
   // Recreate target using the new rendering mode
   RenderingMode attemptedMode = EnsureTarget(aRenderingMode);
   if (!IsTargetValid())
     return false;
 
   // We succeeded, so update mRenderingMode to reflect reality
@@ -1218,18 +1216,16 @@ CanvasRenderingContext2D::EnsureTarget(R
         DemoteOldestContextIfNecessary();
 
         SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
 
 #if USE_SKIA
         if (glue && glue->GetGrContext() && glue->GetGLContext()) {
           mTarget = Factory::CreateDrawTargetSkiaWithGrContext(glue->GetGrContext(), size, format);
           if (mTarget) {
-            mStream = gl::SurfaceStream::CreateForType(gl::SurfaceStreamType::TripleBuffer,
-                                                       glue->GetGLContext());
             AddDemotableContext(this);
           } else {
             printf_stderr("Failed to create a SkiaGL DrawTarget, falling back to software\n");
             mode = RenderingMode::SoftwareBackendMode;
           }
         }
 #endif
         if (!mTarget) {
@@ -4852,25 +4848,22 @@ CanvasRenderingContext2D::GetCanvasLayer
   mTarget->Flush();
 
   if (!mResetLayer && aOldLayer) {
     CanvasRenderingContext2DUserData* userData =
       static_cast<CanvasRenderingContext2DUserData*>(
         aOldLayer->GetUserData(&g2DContextLayerUserData));
 
     CanvasLayer::Data data;
-    if (mStream) {
-#ifdef USE_SKIA
-      SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
-
-      if (glue) {
-        data.mGLContext = glue->GetGLContext();
-        data.mStream = mStream.get();
-      }
-#endif
+
+    SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
+    GLuint skiaGLTex = (GLuint)(uintptr_t)mTarget->GetNativeSurface(NativeSurfaceType::OPENGL_TEXTURE);
+    if (glue && skiaGLTex) {
+      data.mGLContext = glue->GetGLContext();
+      data.mFrontbufferGLTex = skiaGLTex;
     } else {
       data.mDrawTarget = mTarget;
     }
 
     if (userData && userData->IsForContext(this) && aOldLayer->IsDataValid(data)) {
       nsRefPtr<CanvasLayer> ret = aOldLayer;
       return ret.forget();
     }
@@ -4897,35 +4890,30 @@ CanvasRenderingContext2D::GetCanvasLayer
   // The userData will receive DidTransactionCallbacks, which flush the
   // the invalidation state to indicate that the canvas is up to date.
   userData = new CanvasRenderingContext2DUserData(this);
   canvasLayer->SetDidTransactionCallback(
           CanvasRenderingContext2DUserData::DidTransactionCallback, userData);
   canvasLayer->SetUserData(&g2DContextLayerUserData, userData);
 
   CanvasLayer::Data data;
-  if (mStream) {
-    SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
-
-    if (glue) {
-      canvasLayer->SetPreTransactionCallback(
-              CanvasRenderingContext2DUserData::PreTransactionCallback, userData);
-#if USE_SKIA
-      data.mGLContext = glue->GetGLContext();
-#endif
-      data.mStream = mStream.get();
-      data.mTexID = (uint32_t)((uintptr_t)mTarget->GetNativeSurface(NativeSurfaceType::OPENGL_TEXTURE));
-    }
+  data.mSize = nsIntSize(mWidth, mHeight);
+  data.mHasAlpha = !mOpaque;
+
+  SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
+  GLuint skiaGLTex = (GLuint)(uintptr_t)mTarget->GetNativeSurface(NativeSurfaceType::OPENGL_TEXTURE);
+  if (glue && skiaGLTex) {
+    canvasLayer->SetPreTransactionCallback(
+            CanvasRenderingContext2DUserData::PreTransactionCallback, userData);
+    data.mGLContext = glue->GetGLContext();
+    data.mFrontbufferGLTex = skiaGLTex;
   } else {
     data.mDrawTarget = mTarget;
   }
 
-  data.mSize = nsIntSize(mWidth, mHeight);
-  data.mHasAlpha = !mOpaque;
-
   canvasLayer->Initialize(data);
   uint32_t flags = mOpaque ? Layer::CONTENT_OPAQUE : 0;
   canvasLayer->SetContentFlags(flags);
   canvasLayer->Updated();
 
   mResetLayer = false;
 
   return canvasLayer.forget();
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -29,17 +29,16 @@
 #include "nsSVGEffects.h"
 
 class nsGlobalWindow;
 class nsXULElement;
 
 namespace mozilla {
 namespace gl {
 class SourceSurface;
-class SurfaceStream;
 }
 
 namespace dom {
 class HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement;
 class ImageData;
 class StringOrCanvasGradientOrCanvasPattern;
 class OwningStringOrCanvasGradientOrCanvasPattern;
 class TextMetrics;
@@ -760,18 +759,16 @@ protected:
   // If mCanvasElement is not provided, then a docshell is
   nsCOMPtr<nsIDocShell> mDocShell;
 
   // This is created lazily so it is necessary to call EnsureTarget before
   // accessing it. In the event of an error it will be equal to
   // sErrorTarget.
   mozilla::RefPtr<mozilla::gfx::DrawTarget> mTarget;
 
-  RefPtr<gl::SurfaceStream> mStream;
-
   /**
     * Flag to avoid duplicate calls to InvalidateFrame. Set to true whenever
     * Redraw is called, reset to false when Render is called.
     */
   bool mIsEntireFrameInvalid;
   /**
     * When this is set, the first call to Redraw(gfxRect) should set
     * mIsEntireFrameInvalid since we expect it will be followed by
--- a/dom/canvas/WebGL2Context.cpp
+++ b/dom/canvas/WebGL2Context.cpp
@@ -60,20 +60,23 @@ WebGL2Context::WrapObject(JSContext *cx)
 bool
 WebGLContext::InitWebGL2()
 {
     MOZ_ASSERT(IsWebGL2(), "WebGLContext is not a WebGL 2 context!");
 
     const WebGLExtensionID sExtensionNativelySupportedArr[] = {
         WebGLExtensionID::ANGLE_instanced_arrays,
         WebGLExtensionID::EXT_blend_minmax,
+        WebGLExtensionID::EXT_sRGB,
         WebGLExtensionID::OES_element_index_uint,
         WebGLExtensionID::OES_standard_derivatives,
         WebGLExtensionID::OES_texture_float,
         WebGLExtensionID::OES_texture_float_linear,
+        WebGLExtensionID::OES_texture_half_float,
+        WebGLExtensionID::OES_texture_half_float_linear,
         WebGLExtensionID::OES_vertex_array_object,
         WebGLExtensionID::WEBGL_depth_texture,
         WebGLExtensionID::WEBGL_draw_buffers
     };
     const GLFeature sFeatureRequiredArr[] = {
         GLFeature::instanced_non_arrays,
         GLFeature::transform_feedback2
     };
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -656,19 +656,23 @@ CreateOffscreen(GLContext* gl,
                 layers::ISurfaceAllocator* surfAllocator)
 {
     SurfaceCaps baseCaps;
 
     baseCaps.color = true;
     baseCaps.alpha = options.alpha;
     baseCaps.antialias = options.antialias;
     baseCaps.depth = options.depth;
+    baseCaps.premultAlpha = options.premultipliedAlpha;
     baseCaps.preserve = options.preserveDrawingBuffer;
     baseCaps.stencil = options.stencil;
 
+    if (!baseCaps.alpha)
+        baseCaps.premultAlpha = true;
+
     // we should really have this behind a
     // |gfxPlatform::GetPlatform()->GetScreenDepth() == 16| check, but
     // for now it's just behind a pref for testing/evaluation.
     baseCaps.bpp16 = Preferences::GetBool("webgl.prefer-16bpp", false);
 
 #ifdef MOZ_WIDGET_GONK
     baseCaps.surfaceAllocator = surfAllocator;
 #endif
@@ -1416,20 +1420,24 @@ WebGLContext::PresentScreenBuffer()
 {
     if (IsContextLost()) {
         return false;
     }
 
     if (!mShouldPresent) {
         return false;
     }
+    MOZ_ASSERT(!mBackbufferNeedsClear);
 
     gl->MakeCurrent();
-    MOZ_ASSERT(!mBackbufferNeedsClear);
-    if (!gl->PublishFrame()) {
+
+    GLScreenBuffer* screen = gl->Screen();
+    MOZ_ASSERT(screen);
+
+    if (!screen->PublishFrame(screen->Size())) {
         ForceLoseContext();
         return false;
     }
 
     if (!mOptions.preserveDrawingBuffer) {
         mBackbufferNeedsClear = true;
     }
 
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1076,18 +1076,16 @@ protected:
 
     virtual bool IsWebGL2() const = 0;
 
     bool InitWebGL2();
 
 
     // -------------------------------------------------------------------------
     // Validation functions (implemented in WebGLContextValidate.cpp)
-    TexInternalFormat BaseTexFormat(TexInternalFormat internalFormat) const;
-
     bool CreateOffscreenGL(bool forceEnabled);
     bool InitAndValidateGL();
     bool ResizeBackbuffer(uint32_t width, uint32_t height);
     bool ValidateBlendEquationEnum(GLenum cap, const char *info);
     bool ValidateBlendFuncDstEnum(GLenum mode, const char *info);
     bool ValidateBlendFuncSrcEnum(GLenum mode, const char *info);
     bool ValidateBlendFuncEnumsCompatibility(GLenum sfactor, GLenum dfactor, const char *info);
     bool ValidateTextureTargetEnum(GLenum target, const char *info);
@@ -1160,17 +1158,17 @@ protected:
                             GLenum format,
                             GLenum type,
                             void *pixels, uint32_t byteLength,
                             int jsArrayType,
                             WebGLTexelFormat srcFormat, bool srcPremultiplied);
     void TexParameter_base(GLenum target, GLenum pname,
                            GLint *intParamPtr, GLfloat *floatParamPtr);
 
-    void ConvertImage(size_t width, size_t height, size_t srcStride, size_t dstStride,
+    bool ConvertImage(size_t width, size_t height, size_t srcStride, size_t dstStride,
                       const uint8_t* src, uint8_t *dst,
                       WebGLTexelFormat srcFormat, bool srcPremultiplied,
                       WebGLTexelFormat dstFormat, bool dstPremultiplied,
                       size_t dstTexelSize);
 
     template<class ElementType>
     nsLayoutUtils::SurfaceFromElementResult SurfaceFromElement(ElementType* aElement) {
         MOZ_ASSERT(aElement);
--- a/dom/canvas/WebGLContextExtensions.cpp
+++ b/dom/canvas/WebGLContextExtensions.cpp
@@ -96,16 +96,18 @@ bool WebGLContext::IsExtensionSupported(
 
 bool WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const
 {
     if (mDisableExtensions) {
         return false;
     }
 
     switch (ext) {
+        case WebGLExtensionID::EXT_blend_minmax:
+            return WebGLExtensionBlendMinMax::IsSupported(this);
         case WebGLExtensionID::OES_element_index_uint:
             return gl->IsSupported(GLFeature::element_index_uint);
         case WebGLExtensionID::OES_standard_derivatives:
             return gl->IsSupported(GLFeature::standard_derivatives);
         case WebGLExtensionID::WEBGL_lose_context:
             // We always support this extension.
             return true;
         case WebGLExtensionID::OES_texture_float:
@@ -160,18 +162,16 @@ bool WebGLContext::IsExtensionSupported(
             return gl->IsExtensionSupported(GLContext::EXT_shader_texture_lod);
         default:
             // For warnings-as-errors.
             break;
     }
 
     if (Preferences::GetBool("webgl.enable-draft-extensions", false) || IsWebGL2()) {
         switch (ext) {
-            case WebGLExtensionID::EXT_blend_minmax:
-                return WebGLExtensionBlendMinMax::IsSupported(this);
             case WebGLExtensionID::EXT_color_buffer_half_float:
                 return WebGLExtensionColorBufferHalfFloat::IsSupported(this);
             case WebGLExtensionID::WEBGL_color_buffer_float:
                 return WebGLExtensionColorBufferFloat::IsSupported(this);
             default:
                 // For warnings-as-errors.
                 break;
         }
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -406,29 +406,29 @@ WebGLContext::CopyTexSubImage2D_base(Tex
         TexInternalFormat framebuffereffectiveformat = mBoundFramebuffer->ColorAttachment(0).EffectiveInternalFormat();
         framebuffertype = TypeFromInternalFormat(framebuffereffectiveformat);
     } else {
         // FIXME - here we're assuming that the default framebuffer is backed by UNSIGNED_BYTE
         // that might not always be true, say if we had a 16bpp default framebuffer.
         framebuffertype = LOCAL_GL_UNSIGNED_BYTE;
     }
 
-    TexInternalFormat effectiveinternalformat =
+    TexInternalFormat effectiveInternalFormat =
         EffectiveInternalFormatFromUnsizedInternalFormatAndType(internalformat, framebuffertype);
 
     // this should never fail, validation happened earlier.
-    MOZ_ASSERT(effectiveinternalformat != LOCAL_GL_NONE);
+    MOZ_ASSERT(effectiveInternalFormat != LOCAL_GL_NONE);
 
     // check if the memory size of this texture may change with this call
     bool sizeMayChange = !sub;
     if (!sub && tex->HasImageInfoAt(texImageTarget, level)) {
         const WebGLTexture::ImageInfo& imageInfo = tex->ImageInfoAt(texImageTarget, level);
         sizeMayChange = width != imageInfo.Width() ||
                         height != imageInfo.Height() ||
-                        effectiveinternalformat != imageInfo.EffectiveInternalFormat();
+                        effectiveInternalFormat != imageInfo.EffectiveInternalFormat();
     }
 
     if (sizeMayChange)
         GetAndFlushUnderlyingGLErrors();
 
     if (CanvasUtils::CheckSaneSubrectSize(x, y, width, height, framebufferWidth, framebufferHeight)) {
         if (sub)
             gl->fCopyTexSubImage2D(texImageTarget.get(), level, xoffset, yoffset, x, y, width, height);
@@ -436,17 +436,17 @@ WebGLContext::CopyTexSubImage2D_base(Tex
             gl->fCopyTexImage2D(texImageTarget.get(), level, internalformat.get(), x, y, width, height, 0);
     } else {
 
         // the rect doesn't fit in the framebuffer
 
         // first, we initialize the texture as black
         if (!sub) {
             tex->SetImageInfo(texImageTarget, level, width, height,
-                      effectiveinternalformat,
+                      effectiveInternalFormat,
                       WebGLImageDataStatus::UninitializedImageData);
             tex->DoDeferredImageInitialization(texImageTarget, level);
         }
 
         // if we are completely outside of the framebuffer, we can exit now with our black texture
         if (   x >= framebufferWidth
             || x+width <= 0
             || y >= framebufferHeight
@@ -474,17 +474,17 @@ WebGLContext::CopyTexSubImage2D_base(Tex
         if (error) {
             GenerateWarning("copyTexImage2D generated error %s", ErrorName(error));
             return;
         }
     }
 
     if (!sub) {
         tex->SetImageInfo(texImageTarget, level, width, height,
-                          effectiveinternalformat,
+                          effectiveInternalFormat,
                           WebGLImageDataStatus::InitializedImageData);
     }
 }
 
 void
 WebGLContext::CopyTexImage2D(GLenum rawTexImgTarget,
                              GLint level,
                              GLenum internalformat,
@@ -1166,22 +1166,22 @@ WebGLContext::GetFramebufferAttachmentPa
         }
 
         ErrorInvalidEnumInfo("getFramebufferAttachmentParameter: pname", pname);
         return JS::NullValue();
     } else if (fba.Texture()) {
         switch (pname) {
              case LOCAL_GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
                 if (IsExtensionEnabled(WebGLExtensionID::EXT_sRGB)) {
-                    const TexInternalFormat effectiveinternalformat =
+                    const TexInternalFormat effectiveInternalFormat =
                         fba.Texture()->ImageInfoBase().EffectiveInternalFormat();
                     TexInternalFormat unsizedinternalformat = LOCAL_GL_NONE;
                     TexType type = LOCAL_GL_NONE;
                     UnsizedInternalFormatAndTypeFromEffectiveInternalFormat(
-                        effectiveinternalformat, &unsizedinternalformat, &type);
+                        effectiveInternalFormat, &unsizedinternalformat, &type);
                     MOZ_ASSERT(unsizedinternalformat != LOCAL_GL_NONE);
                     const bool srgb = unsizedinternalformat == LOCAL_GL_SRGB ||
                                       unsizedinternalformat == LOCAL_GL_SRGB_ALPHA;
                     return srgb ? JS::NumberValue(uint32_t(LOCAL_GL_SRGB))
                                 : JS::NumberValue(uint32_t(LOCAL_GL_LINEAR));
                 }
                 break;
 
@@ -1212,19 +1212,19 @@ WebGLContext::GetFramebufferAttachmentPa
                     ErrorInvalidOperation("getFramebufferAttachmentParameter: cannot component"
                                           " type of depth-stencil attachments.");
                     return JS::NullValue();
                 }
 
                 if (!fba.IsComplete())
                     return JS::NumberValue(uint32_t(LOCAL_GL_NONE));
 
-                TexInternalFormat effectiveinternalformat =
+                TexInternalFormat effectiveInternalFormat =
                     fba.Texture()->ImageInfoAt(fba.ImageTarget(), fba.MipLevel()).EffectiveInternalFormat();
-                TexType type = TypeFromInternalFormat(effectiveinternalformat);
+                TexType type = TypeFromInternalFormat(effectiveInternalFormat);
                 GLenum ret = LOCAL_GL_NONE;
                 switch (type.get()) {
                 case LOCAL_GL_UNSIGNED_BYTE:
                 case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4:
                 case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1:
                 case LOCAL_GL_UNSIGNED_SHORT_5_6_5:
                     ret = LOCAL_GL_UNSIGNED_NORMALIZED;
                     break;
@@ -1888,98 +1888,90 @@ bool WebGLContext::BindArrayAttribToLoca
         nsCString& attrName = program->mActiveAttribMap.find(leastArrayLocation)->second;
         const char* attrNameCStr = attrName.get();
         gl->fBindAttribLocation(program->GLName(), 0, attrNameCStr);
         return true;
     }
     return false;
 }
 
+static void
+LinkAndUpdateProgram(GLContext* gl, WebGLProgram* prog)
+{
+    GLuint name = prog->GLName();
+    gl->fLinkProgram(name);
+
+    prog->SetLinkStatus(false);
+
+    GLint ok = 0;
+    gl->fGetProgramiv(name, LOCAL_GL_LINK_STATUS, &ok);
+    if (!ok)
+        return;
+
+    if (!prog->UpdateInfo())
+        return;
+
+    prog->SetLinkStatus(true);
+}
+
 void
 WebGLContext::LinkProgram(WebGLProgram *program)
 {
     if (IsContextLost())
         return;
 
     if (!ValidateObject("linkProgram", program))
         return;
 
     InvalidateBufferFetching(); // we do it early in this function
     // as some of the validation below changes program state
 
-    GLuint progname = program->GLName();
-
     if (!program->NextGeneration()) {
         // XXX throw?
         return;
     }
 
     if (!program->HasBothShaderTypesAttached()) {
-        GenerateWarning("linkProgram: this program doesn't have both a vertex shader"
-                        " and a fragment shader");
+        GenerateWarning("linkProgram: this program doesn't have both a vertex"
+                        " shader and a fragment shader");
+        program->SetLinkStatus(false);
+        return;
+    }
+
+    if (program->HasBadShaderAttached()) {
+        GenerateWarning("linkProgram: The program has bad shaders attached.");
         program->SetLinkStatus(false);
         return;
     }
 
     // bug 777028
     // Mesa can't handle more than 16 samplers per program, counting each array entry.
     if (gl->WorkAroundDriverBugs() &&
         mIsMesa &&
         program->UpperBoundNumSamplerUniforms() > 16)
     {
-        GenerateWarning("Programs with more than 16 samplers are disallowed on Mesa drivers " "to avoid a Mesa crasher.");
+        GenerateWarning("Programs with more than 16 samplers are disallowed on"
+                        " Mesa drivers to avoid a Mesa crasher.");
         program->SetLinkStatus(false);
         return;
     }
 
-    bool updateInfoSucceeded = false;
-    GLint ok = 0;
-    if (gl->WorkAroundDriverBugs() &&
-        program->HasBadShaderAttached())
-    {
-        // it's a common driver bug, caught by program-test.html, that linkProgram doesn't
-        // correctly preserve the state of an in-use program that has been attached a bad shader
-        // see bug 777883
-        ok = false;
-    } else {
-        MakeContextCurrent();
-        gl->fLinkProgram(progname);
-        gl->fGetProgramiv(progname, LOCAL_GL_LINK_STATUS, &ok);
-
-        if (ok) {
-            updateInfoSucceeded = program->UpdateInfo();
-            program->SetLinkStatus(updateInfoSucceeded);
-
-            if (BindArrayAttribToLocation0(program)) {
-                GenerateWarning("linkProgram: relinking program to make attrib0 an "
-                                "array.");
-                gl->fLinkProgram(progname);
-                gl->fGetProgramiv(progname, LOCAL_GL_LINK_STATUS, &ok);
-                if (ok) {
-                    updateInfoSucceeded = program->UpdateInfo();
-                    program->SetLinkStatus(updateInfoSucceeded);
-                }
-            }
+    MakeContextCurrent();
+    LinkAndUpdateProgram(gl, program);
+
+    if (program->LinkStatus()) {
+        if (BindArrayAttribToLocation0(program)) {
+            GenerateWarning("linkProgram: Relinking program to make attrib0 an"
+                            " array.");
+            LinkAndUpdateProgram(gl, program);
         }
     }
 
-    if (ok) {
-        // Bug 750527
-        if (gl->WorkAroundDriverBugs() &&
-            updateInfoSucceeded &&
-            gl->Vendor() == gl::GLVendor::NVIDIA)
-        {
-            if (program == mCurrentProgram)
-                gl->fUseProgram(progname);
-        }
-    } else {
-        program->SetLinkStatus(false);
-
+    if (!program->LinkStatus()) {
         if (ShouldGenerateWarnings()) {
-
             // report shader/program infoLogs as warnings.
             // note that shader compilation errors can be deferred to linkProgram,
             // which is why we can't do anything in compileShader. In practice we could
             // report in compileShader the translation errors generated by ANGLE,
             // but it seems saner to keep a single way of obtaining shader infologs.
 
             nsAutoCString log;
 
@@ -2015,16 +2007,24 @@ WebGLContext::LinkProgram(WebGLProgram *
             if (!alreadyReportedShaderInfoLog) {
                 GetProgramInfoLog(program, log);
                 if (!log.IsEmpty()) {
                     GenerateWarning("linkProgram failed, with this log:\n%s\n",
                                     log.get());
                 }
             }
         }
+        return;
+    }
+
+    if (gl->WorkAroundDriverBugs() &&
+        gl->Vendor() == gl::GLVendor::NVIDIA)
+    {
+        if (program == mCurrentProgram)
+            gl->fUseProgram(program->GLName());
     }
 }
 
 void
 WebGLContext::PixelStorei(GLenum pname, GLint param)
 {
     if (IsContextLost())
         return;
@@ -3662,38 +3662,48 @@ WebGLContext::TexImage2D_base(TexImageTa
                           border, format, type, func))
     {
         return;
     }
 
     const bool isDepthTexture = format == LOCAL_GL_DEPTH_COMPONENT ||
                                 format == LOCAL_GL_DEPTH_STENCIL;
 
-    if (isDepthTexture) {
+    if (isDepthTexture && !IsWebGL2()) {
         if (data != nullptr || level != 0)
             return ErrorInvalidOperation("texImage2D: "
                                          "with format of DEPTH_COMPONENT or DEPTH_STENCIL, "
                                          "data must be nullptr, "
                                          "level must be zero");
     }
 
     if (!ValidateTexInputData(type, jsArrayType, func))
         return;
 
-    TexInternalFormat effectiveinternalformat =
+    TexInternalFormat effectiveInternalFormat =
         EffectiveInternalFormatFromInternalFormatAndType(internalformat, type);
 
-    if (effectiveinternalformat == LOCAL_GL_NONE) {
+    if (effectiveInternalFormat == LOCAL_GL_NONE) {
         return ErrorInvalidOperation("texImage2D: bad combination of internalformat and type");
     }
 
-    WebGLTexelFormat dstFormat = GetWebGLTexelFormat(effectiveinternalformat);
-    WebGLTexelFormat actualSrcFormat = srcFormat == WebGLTexelFormat::Auto ? dstFormat : srcFormat;
-
-    uint32_t srcTexelSize = WebGLTexelConversions::TexelBytesForFormat(actualSrcFormat);
+    size_t srcTexelSize = size_t(-1);
+    if (srcFormat == WebGLTexelFormat::Auto) {
+        // we need to find the exact sized format of the source data. Slightly abusing
+        // EffectiveInternalFormatFromInternalFormatAndType for that purpose. Really, an unsized source format
+        // is the same thing as an unsized internalformat.
+        TexInternalFormat effectiveSourceFormat =
+            EffectiveInternalFormatFromInternalFormatAndType(format, type);
+        MOZ_ASSERT(effectiveSourceFormat != LOCAL_GL_NONE); // should have validated format/type combo earlier
+        const size_t srcbitsPerTexel = GetBitsPerTexel(effectiveSourceFormat);
+        MOZ_ASSERT((srcbitsPerTexel % 8) == 0); // should not have compressed formats here.
+        srcTexelSize = srcbitsPerTexel / 8;
+    } else {
+        srcTexelSize = WebGLTexelConversions::TexelBytesForFormat(srcFormat);
+    }
 
     CheckedUint32 checked_neededByteLength =
         GetImageSize(height, width, srcTexelSize, mPixelStoreUnpackAlignment);
 
     CheckedUint32 checked_plainRowSize = CheckedUint32(width) * srcTexelSize;
     CheckedUint32 checked_alignedRowSize =
         RoundedToNextMultipleOf(checked_plainRowSize.value(), mPixelStoreUnpackAlignment);
 
@@ -3717,20 +3727,23 @@ WebGLContext::TexImage2D_base(TexImageTa
             "bound to this target has already been made immutable by texStorage2D");
     }
     MakeContextCurrent();
 
     nsAutoArrayPtr<uint8_t> convertedData;
     void* pixels = nullptr;
     WebGLImageDataStatus imageInfoStatusIfSuccess = WebGLImageDataStatus::UninitializedImageData;
 
+    WebGLTexelFormat dstFormat = GetWebGLTexelFormat(effectiveInternalFormat);
+    WebGLTexelFormat actualSrcFormat = srcFormat == WebGLTexelFormat::Auto ? dstFormat : srcFormat;
+
     if (byteLength) {
-        size_t   bitspertexel = GetBitsPerTexel(effectiveinternalformat);
-        MOZ_ASSERT((bitspertexel % 8) == 0); // should not have compressed formats here.
-        size_t   dstTexelSize = bitspertexel / 8;
+        size_t   bitsPerTexel = GetBitsPerTexel(effectiveInternalFormat);
+        MOZ_ASSERT((bitsPerTexel % 8) == 0); // should not have compressed formats here.
+        size_t   dstTexelSize = bitsPerTexel / 8;
         size_t   srcStride = srcStrideOrZero ? srcStrideOrZero : checked_alignedRowSize.value();
         size_t   dstPlainRowSize = dstTexelSize * width;
         size_t   unpackAlignment = mPixelStoreUnpackAlignment;
         size_t   dstStride = ((dstPlainRowSize + unpackAlignment-1) / unpackAlignment) * unpackAlignment;
 
         if (actualSrcFormat == dstFormat &&
             srcPremultiplied == mPixelStorePremultiplyAlpha &&
             srcStride == dstStride &&
@@ -3738,20 +3751,23 @@ WebGLContext::TexImage2D_base(TexImageTa
         {
             // no conversion, no flipping, so we avoid copying anything and just pass the source pointer
             pixels = data;
         }
         else
         {
             size_t convertedDataSize = height * dstStride;
             convertedData = new uint8_t[convertedDataSize];
-            ConvertImage(width, height, srcStride, dstStride,
-                        static_cast<uint8_t*>(data), convertedData,
-                        actualSrcFormat, srcPremultiplied,
-                        dstFormat, mPixelStorePremultiplyAlpha, dstTexelSize);
+            if (!ConvertImage(width, height, srcStride, dstStride,
+                              static_cast<uint8_t*>(data), convertedData,
+                              actualSrcFormat, srcPremultiplied,
+                              dstFormat, mPixelStorePremultiplyAlpha, dstTexelSize))
+            {
+                return ErrorInvalidOperation("texImage2D: Unsupported texture format conversion");
+            }
             pixels = reinterpret_cast<void*>(convertedData.get());
         }
         imageInfoStatusIfSuccess = WebGLImageDataStatus::InitializedImageData;
     }
 
     GLenum error = CheckedTexImage2D(texImageTarget, level, internalformat, width,
                                      height, border, format, type, pixels);
 
@@ -3761,17 +3777,17 @@ WebGLContext::TexImage2D_base(TexImageTa
     }
 
     // in all of the code paths above, we should have either initialized data,
     // or allocated data and left it uninitialized, but in any case we shouldn't
     // have NoImageData at this point.
     MOZ_ASSERT(imageInfoStatusIfSuccess != WebGLImageDataStatus::NoImageData);
 
     tex->SetImageInfo(texImageTarget, level, width, height,
-                      effectiveinternalformat, imageInfoStatusIfSuccess);
+                      effectiveInternalFormat, imageInfoStatusIfSuccess);
 }
 
 void
 WebGLContext::TexImage2D(GLenum rawTarget, GLint level,
                          GLenum internalformat, GLsizei width,
                          GLsizei height, GLint border, GLenum format,
                          GLenum type, const Nullable<ArrayBufferView> &pixels, ErrorResult& rv)
 {
@@ -3875,20 +3891,24 @@ WebGLContext::TexSubImage2D_base(TexImag
 
     if (!ValidateTexInputData(type, jsArrayType, func))
         return;
 
     if (type != existingType) {
         return ErrorInvalidOperation("texSubImage2D: type differs from that of the existing image");
     }
 
-    WebGLTexelFormat dstFormat = GetWebGLTexelFormat(existingEffectiveInternalFormat);
-    WebGLTexelFormat actualSrcFormat = srcFormat == WebGLTexelFormat::Auto ? dstFormat : srcFormat;
-
-    uint32_t srcTexelSize = WebGLTexelConversions::TexelBytesForFormat(actualSrcFormat);
+    size_t srcTexelSize = size_t(-1);
+    if (srcFormat == WebGLTexelFormat::Auto) {
+        const size_t bitsPerTexel = GetBitsPerTexel(existingEffectiveInternalFormat);
+        MOZ_ASSERT((bitsPerTexel % 8) == 0); // should not have compressed formats here.
+        srcTexelSize = bitsPerTexel / 8;
+    } else {
+        srcTexelSize = WebGLTexelConversions::TexelBytesForFormat(srcFormat);
+    }
 
     if (width == 0 || height == 0)
         return; // ES 2.0 says it has no effect, we better return right now
 
     CheckedUint32 checked_neededByteLength =
         GetImageSize(height, width, srcTexelSize, mPixelStoreUnpackAlignment);
 
     CheckedUint32 checked_plainRowSize = CheckedUint32(width) * srcTexelSize;
@@ -3913,29 +3933,35 @@ WebGLContext::TexSubImage2D_base(TexImag
     uint32_t dstTexelSize = GetBitsPerTexel(existingEffectiveInternalFormat) / 8;
     size_t   dstPlainRowSize = dstTexelSize * width;
     // There are checks above to ensure that this won't overflow.
     size_t   dstStride = RoundedToNextMultipleOf(dstPlainRowSize, mPixelStoreUnpackAlignment).value();
 
     void* pixels = data;
     nsAutoArrayPtr<uint8_t> convertedData;
 
+    WebGLTexelFormat dstFormat = GetWebGLTexelFormat(existingEffectiveInternalFormat);
+    WebGLTexelFormat actualSrcFormat = srcFormat == WebGLTexelFormat::Auto ? dstFormat : srcFormat;
+
     // no conversion, no flipping, so we avoid copying anything and just pass the source pointer
     bool noConversion = (actualSrcFormat == dstFormat &&
                          srcPremultiplied == mPixelStorePremultiplyAlpha &&
                          srcStride == dstStride &&
                          !mPixelStoreFlipY);
 
     if (!noConversion) {
         size_t convertedDataSize = height * dstStride;
         convertedData = new uint8_t[convertedDataSize];
-        ConvertImage(width, height, srcStride, dstStride,
-                    static_cast<const uint8_t*>(data), convertedData,
-                    actualSrcFormat, srcPremultiplied,
-                    dstFormat, mPixelStorePremultiplyAlpha, dstTexelSize);
+        if (!ConvertImage(width, height, srcStride, dstStride,
+                          static_cast<const uint8_t*>(data), convertedData,
+                          actualSrcFormat, srcPremultiplied,
+                          dstFormat, mPixelStorePremultiplyAlpha, dstTexelSize))
+        {
+            return ErrorInvalidOperation("texSubImage2D: Unsupported texture format conversion");
+        }
         pixels = reinterpret_cast<void*>(convertedData.get());
     }
 
     GLenum driverType = LOCAL_GL_NONE;
     GLenum driverInternalFormat = LOCAL_GL_NONE;
     GLenum driverFormat = LOCAL_GL_NONE;
     DriverFormatsFromEffectiveInternalFormat(gl,
                                              existingEffectiveInternalFormat,
@@ -4094,22 +4120,19 @@ BaseTypeAndSizeFromUniformType(GLenum uT
             return false;
     }
 
     return true;
 }
 
 
 WebGLTexelFormat
-mozilla::GetWebGLTexelFormat(TexInternalFormat effectiveinternalformat)
+mozilla::GetWebGLTexelFormat(TexInternalFormat effectiveInternalFormat)
 {
-    switch (effectiveinternalformat.get()) {
-        case LOCAL_GL_DEPTH_COMPONENT16:      return WebGLTexelFormat::D16;
-        case LOCAL_GL_DEPTH_COMPONENT24:      return WebGLTexelFormat::D32;
-        case LOCAL_GL_DEPTH24_STENCIL8:       return WebGLTexelFormat::D24S8;
+    switch (effectiveInternalFormat.get()) {
         case LOCAL_GL_RGBA8:                  return WebGLTexelFormat::RGBA8;
         case LOCAL_GL_SRGB8_ALPHA8:           return WebGLTexelFormat::RGBA8;
         case LOCAL_GL_RGB8:                   return WebGLTexelFormat::RGB8;
         case LOCAL_GL_SRGB8:                  return WebGLTexelFormat::RGB8;
         case LOCAL_GL_ALPHA8:                 return WebGLTexelFormat::A8;
         case LOCAL_GL_LUMINANCE8:             return WebGLTexelFormat::R8;
         case LOCAL_GL_LUMINANCE8_ALPHA8:      return WebGLTexelFormat::RA8;
         case LOCAL_GL_RGBA32F:                return WebGLTexelFormat::RGBA32F;
@@ -4121,18 +4144,17 @@ mozilla::GetWebGLTexelFormat(TexInternal
         case LOCAL_GL_RGB16F:                 return WebGLTexelFormat::RGB16F;
         case LOCAL_GL_ALPHA16F_EXT:           return WebGLTexelFormat::A16F;
         case LOCAL_GL_LUMINANCE16F_EXT:       return WebGLTexelFormat::R16F;
         case LOCAL_GL_LUMINANCE_ALPHA16F_EXT: return WebGLTexelFormat::RA16F;
         case LOCAL_GL_RGBA4:                  return WebGLTexelFormat::RGBA4444;
         case LOCAL_GL_RGB5_A1:                return WebGLTexelFormat::RGBA5551;
         case LOCAL_GL_RGB565:                 return WebGLTexelFormat::RGB565;
         default:
-            MOZ_CRASH("Unhandled format");
-            return WebGLTexelFormat::BadFormat;
+            return WebGLTexelFormat::FormatNotSupportingAnyConversion;
     }
 }
 
 void
 WebGLContext::BlendColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) {
     if (IsContextLost())
         return;
     MakeContextCurrent();
--- a/dom/canvas/WebGLContextUtils.cpp
+++ b/dom/canvas/WebGLContextUtils.cpp
@@ -252,16 +252,28 @@ DriverFormatsFromEffectiveInternalFormat
     if (!gl->IsGLES()) {
         // Cases where desktop OpenGL requires a tweak to 'format'
         if (driverFormat == LOCAL_GL_SRGB) {
             driverFormat = LOCAL_GL_RGB;
         } else if (driverFormat == LOCAL_GL_SRGB_ALPHA) {
             driverFormat = LOCAL_GL_RGBA;
         }
 
+        // WebGL2's new formats are not legal values for internalformat,
+        // as using unsized internalformat is deprecated.
+        if (driverFormat == LOCAL_GL_RED ||
+            driverFormat == LOCAL_GL_RG ||
+            driverFormat == LOCAL_GL_RED_INTEGER ||
+            driverFormat == LOCAL_GL_RG_INTEGER ||
+            driverFormat == LOCAL_GL_RGB_INTEGER ||
+            driverFormat == LOCAL_GL_RGBA_INTEGER)
+        {
+            driverInternalFormat = effectiveinternalformat.get();
+        }
+
         // Cases where desktop OpenGL requires a sized internalformat,
         // as opposed to the unsized internalformat that had the same
         // GLenum value as 'format', in order to get the precise
         // semantics that we want. For example, for floating-point formats,
         // we seem to need a sized internalformat to get non-clamped floating
         // point texture sampling. Can't find the spec reference for that,
         // but that's at least the case on my NVIDIA driver version 331.
         if (unsizedinternalformat == LOCAL_GL_DEPTH_COMPONENT ||
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -157,190 +157,16 @@ IsSubFunc(WebGLTexImageFunc func)
  */
 static bool
 IsTexImageCubemapTarget(GLenum texImageTarget)
 {
     return (texImageTarget >= LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
             texImageTarget <= LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
 }
 
-/*
- * Pull data out of the program, post-linking
- */
-bool
-WebGLProgram::UpdateInfo()
-{
-    mAttribMaxNameLength = 0;
-    for (size_t i = 0; i < mAttachedShaders.Length(); i++)
-        mAttribMaxNameLength = std::max(mAttribMaxNameLength, mAttachedShaders[i]->mAttribMaxNameLength);
-
-    GLint attribCount;
-    mContext->gl->fGetProgramiv(mGLName, LOCAL_GL_ACTIVE_ATTRIBUTES, &attribCount);
-
-    if (!mAttribsInUse.SetLength(mContext->mGLMaxVertexAttribs)) {
-        mContext->ErrorOutOfMemory("updateInfo: out of memory to allocate %d attribs", mContext->mGLMaxVertexAttribs);
-        return false;
-    }
-
-    for (size_t i = 0; i < mAttribsInUse.Length(); i++)
-        mAttribsInUse[i] = false;
-
-    nsAutoArrayPtr<char> nameBuf(new char[mAttribMaxNameLength]);
-
-    for (int i = 0; i < attribCount; ++i) {
-        GLint attrnamelen;
-        GLint attrsize;
-        GLenum attrtype;
-        mContext->gl->fGetActiveAttrib(mGLName, i, mAttribMaxNameLength, &attrnamelen, &attrsize, &attrtype, nameBuf);
-        if (attrnamelen > 0) {
-            GLint loc = mContext->gl->fGetAttribLocation(mGLName, nameBuf);
-            MOZ_ASSERT(loc >= 0, "major oops in managing the attributes of a WebGL program");
-            if (loc < mContext->mGLMaxVertexAttribs) {
-                mAttribsInUse[loc] = true;
-            } else {
-                mContext->GenerateWarning("program exceeds MAX_VERTEX_ATTRIBS");
-                return false;
-            }
-        }
-    }
-
-    // nsAutoPtr will delete old version first
-    mIdentifierMap = new CStringMap;
-    mIdentifierReverseMap = new CStringMap;
-    mUniformInfoMap = new CStringToUniformInfoMap;
-    for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
-        // Loop through ATTRIBUTES
-        for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) {
-            const WebGLMappedIdentifier& attrib = mAttachedShaders[i]->mAttributes[j];
-            mIdentifierMap->Put(attrib.original, attrib.mapped); // FORWARD MAPPING
-            mIdentifierReverseMap->Put(attrib.mapped, attrib.original); // REVERSE MAPPING
-        }
-
-        // Loop through UNIFORMS
-        for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) {
-            // Add the uniforms name mapping to mIdentifier[Reverse]Map
-            const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j];
-            mIdentifierMap->Put(uniform.original, uniform.mapped); // FOWARD MAPPING
-            mIdentifierReverseMap->Put(uniform.mapped, uniform.original); // REVERSE MAPPING
-
-            // Add uniform info to mUniformInfoMap
-            const WebGLUniformInfo& info = mAttachedShaders[i]->mUniformInfos[j];
-            mUniformInfoMap->Put(uniform.mapped, info);
-        }
-    }
-
-    mActiveAttribMap.clear();
-
-    GLint numActiveAttrs = 0;
-    mContext->gl->fGetProgramiv(mGLName, LOCAL_GL_ACTIVE_ATTRIBUTES, &numActiveAttrs);
-
-    // Spec says the maximum attrib name length is 256 chars, so this is
-    // sufficient to hold any attrib name.
-    char attrName[257];
-
-    GLint dummySize;
-    GLenum dummyType;
-    for (GLint i = 0; i < numActiveAttrs; i++) {
-        mContext->gl->fGetActiveAttrib(mGLName, i, 257, nullptr, &dummySize,
-                                       &dummyType, attrName);
-        GLint attrLoc = mContext->gl->fGetAttribLocation(mGLName, attrName);
-        MOZ_ASSERT(attrLoc >= 0);
-        mActiveAttribMap.insert(std::make_pair(attrLoc, nsCString(attrName)));
-    }
-
-    return true;
-}
-
-/**
- * Return the simple base format for a given internal format.
- *
- * \return the corresponding \u base internal format (GL_ALPHA, GL_LUMINANCE,
- * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA), or GL_NONE if invalid enum.
- */
-TexInternalFormat
-WebGLContext::BaseTexFormat(TexInternalFormat internalFormat) const
-{
-    if (internalFormat == LOCAL_GL_ALPHA ||
-        internalFormat == LOCAL_GL_LUMINANCE ||
-        internalFormat == LOCAL_GL_LUMINANCE_ALPHA ||
-        internalFormat == LOCAL_GL_RGB ||
-        internalFormat == LOCAL_GL_RGBA)
-    {
-        return internalFormat;
-    }
-
-    if (IsExtensionEnabled(WebGLExtensionID::EXT_sRGB)) {
-        if (internalFormat == LOCAL_GL_SRGB)
-            return LOCAL_GL_RGB;
-
-        if (internalFormat == LOCAL_GL_SRGB_ALPHA)
-            return LOCAL_GL_RGBA;
-    }
-
-    if (IsExtensionEnabled(WebGLExtensionID::WEBGL_compressed_texture_atc)) {
-        if (internalFormat == LOCAL_GL_ATC_RGB)
-            return LOCAL_GL_RGB;
-
-        if (internalFormat == LOCAL_GL_ATC_RGBA_EXPLICIT_ALPHA ||
-            internalFormat == LOCAL_GL_ATC_RGBA_INTERPOLATED_ALPHA)
-        {
-            return LOCAL_GL_RGBA;
-        }
-    }
-
-    if (IsExtensionEnabled(WebGLExtensionID::WEBGL_compressed_texture_etc1)) {
-        if (internalFormat == LOCAL_GL_ETC1_RGB8_OES)
-            return LOCAL_GL_RGB;
-    }
-
-    if (IsExtensionEnabled(WebGLExtensionID::WEBGL_compressed_texture_pvrtc)) {
-        if (internalFormat == LOCAL_GL_COMPRESSED_RGB_PVRTC_2BPPV1 ||
-            internalFormat == LOCAL_GL_COMPRESSED_RGB_PVRTC_4BPPV1)
-        {
-            return LOCAL_GL_RGB;
-        }
-
-        if (internalFormat == LOCAL_GL_COMPRESSED_RGBA_PVRTC_2BPPV1 ||
-            internalFormat == LOCAL_GL_COMPRESSED_RGBA_PVRTC_4BPPV1)
-        {
-            return LOCAL_GL_RGBA;
-        }
-    }
-
-    if (IsExtensionEnabled(WebGLExtensionID::WEBGL_compressed_texture_s3tc)) {
-        if (internalFormat == LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
-            return LOCAL_GL_RGB;
-
-        if (internalFormat == LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||
-            internalFormat == LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ||
-            internalFormat == LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
-        {
-            return LOCAL_GL_RGBA;
-        }
-    }
-
-    if (IsExtensionEnabled(WebGLExtensionID::WEBGL_depth_texture)) {
-        if (internalFormat == LOCAL_GL_DEPTH_COMPONENT ||
-            internalFormat == LOCAL_GL_DEPTH_COMPONENT16 ||
-            internalFormat == LOCAL_GL_DEPTH_COMPONENT32)
-        {
-            return LOCAL_GL_DEPTH_COMPONENT;
-        }
-
-        if (internalFormat == LOCAL_GL_DEPTH_STENCIL ||
-            internalFormat == LOCAL_GL_DEPTH24_STENCIL8)
-        {
-            return LOCAL_GL_DEPTH_STENCIL;
-        }
-    }
-
-    MOZ_ASSERT(false, "Unhandled internalFormat");
-    return LOCAL_GL_NONE;
-}
-
 bool WebGLContext::ValidateBlendEquationEnum(GLenum mode, const char *info)
 {
     switch (mode) {
         case LOCAL_GL_FUNC_ADD:
         case LOCAL_GL_FUNC_SUBTRACT:
         case LOCAL_GL_FUNC_REVERSE_SUBTRACT:
             return true;
         case LOCAL_GL_MIN:
@@ -567,29 +393,46 @@ WebGLContext::ValidateTexImageFormat(GLe
         format == LOCAL_GL_RGB ||
         format == LOCAL_GL_RGBA ||
         format == LOCAL_GL_LUMINANCE ||
         format == LOCAL_GL_LUMINANCE_ALPHA)
     {
         return true;
     }
 
+    /* WebGL2 new formats */
+    if (format == LOCAL_GL_RED ||
+        format == LOCAL_GL_RG ||
+        format == LOCAL_GL_RED_INTEGER ||
+        format == LOCAL_GL_RG_INTEGER ||
+        format == LOCAL_GL_RGB_INTEGER ||
+        format == LOCAL_GL_RGBA_INTEGER)
+    {
+        bool valid = IsWebGL2();
+        if (!valid) {
+            ErrorInvalidEnum("%s:  invalid format %s: requires WebGL version 2.0 or newer",
+                             InfoFrom(func), EnumName(format));
+        }
+        return valid;
+    }
+
     /* WEBGL_depth_texture added formats */
     if (format == LOCAL_GL_DEPTH_COMPONENT ||
         format == LOCAL_GL_DEPTH_STENCIL)
     {
         if (!IsExtensionEnabled(WebGLExtensionID::WEBGL_depth_texture)) {
             ErrorInvalidEnum("%s: invalid format %s: need WEBGL_depth_texture enabled",
                              InfoFrom(func), EnumName(format));
             return false;
         }
 
         // If WEBGL_depth_texture is enabled, then it is not allowed to be used with the
-        // texSubImage, copyTexImage, or copyTexSubImage methods
-        if (func == WebGLTexImageFunc::TexSubImage ||
+        // copyTexImage, or copyTexSubImage methods, and it is not allowed with
+        // texSubImage in WebGL1.
+        if ((func == WebGLTexImageFunc::TexSubImage && !IsWebGL2()) ||
             func == WebGLTexImageFunc::CopyTexImage ||
             func == WebGLTexImageFunc::CopyTexSubImage)
         {
             ErrorInvalidOperation("%s: format %s is not supported", InfoFrom(func), EnumName(format));
             return false;
         }
 
         return true;
@@ -658,16 +501,33 @@ WebGLContext::ValidateTexImageType(GLenu
     if (type == LOCAL_GL_UNSIGNED_BYTE ||
         type == LOCAL_GL_UNSIGNED_SHORT_5_6_5 ||
         type == LOCAL_GL_UNSIGNED_SHORT_4_4_4_4 ||
         type == LOCAL_GL_UNSIGNED_SHORT_5_5_5_1)
     {
         return true;
     }
 
+    /* WebGL2 new types */
+    if (type == LOCAL_GL_BYTE ||
+        type == LOCAL_GL_SHORT ||
+        type == LOCAL_GL_INT ||
+        type == LOCAL_GL_FLOAT_32_UNSIGNED_INT_24_8_REV ||
+        type == LOCAL_GL_UNSIGNED_INT_2_10_10_10_REV ||
+        type == LOCAL_GL_UNSIGNED_INT_10F_11F_11F_REV ||
+        type == LOCAL_GL_UNSIGNED_INT_5_9_9_9_REV)
+    {
+        bool validType = IsWebGL2();
+        if (!validType) {
+            ErrorInvalidEnum("%s: invalid type %s: requires WebGL version 2.0 or newer",
+                             InfoFrom(func), WebGLContext::EnumName(type));
+        }
+        return validType;
+    }
+
     /* OES_texture_float added types */
     if (type == LOCAL_GL_FLOAT) {
         bool validType = IsExtensionEnabled(WebGLExtensionID::OES_texture_float);
         if (!validType)
             ErrorInvalidEnum("%s: invalid type %s: need OES_texture_float enabled",
                              InfoFrom(func), WebGLContext::EnumName(type));
         return validType;
     }
@@ -1039,60 +899,22 @@ WebGLContext::ValidateTexImageFormatAndT
         return true;
     }
     if (!ValidateTexImageFormat(format, func) ||
         !ValidateTexImageType(type, func))
     {
         return false;
     }
 
-    bool validCombo = false;
-
-    switch (format) {
-    case LOCAL_GL_ALPHA:
-    case LOCAL_GL_LUMINANCE:
-    case LOCAL_GL_LUMINANCE_ALPHA:
-        validCombo = (type == LOCAL_GL_UNSIGNED_BYTE ||
-                      type == LOCAL_GL_HALF_FLOAT ||
-                      type == LOCAL_GL_FLOAT);
-        break;
-
-    case LOCAL_GL_RGB:
-    case LOCAL_GL_SRGB:
-        validCombo = (type == LOCAL_GL_UNSIGNED_BYTE ||
-                      type == LOCAL_GL_UNSIGNED_SHORT_5_6_5 ||
-                      type == LOCAL_GL_HALF_FLOAT ||
-                      type == LOCAL_GL_FLOAT);
-        break;
-
-    case LOCAL_GL_RGBA:
-    case LOCAL_GL_SRGB_ALPHA:
-        validCombo = (type == LOCAL_GL_UNSIGNED_BYTE ||
-                      type == LOCAL_GL_UNSIGNED_SHORT_4_4_4_4 ||
-                      type == LOCAL_GL_UNSIGNED_SHORT_5_5_5_1 ||
-                      type == LOCAL_GL_HALF_FLOAT ||
-                      type == LOCAL_GL_FLOAT);
-        break;
-
-    case LOCAL_GL_DEPTH_COMPONENT:
-        validCombo = (type == LOCAL_GL_UNSIGNED_SHORT ||
-                      type == LOCAL_GL_UNSIGNED_INT);
-        break;
-
-    case LOCAL_GL_DEPTH_STENCIL:
-        validCombo = (type == LOCAL_GL_UNSIGNED_INT_24_8);
-        break;
-
-    default:
-        // Only valid formats should be passed to the switch stmt.
-        MOZ_ASSERT(false, "Unexpected format and type combo. How'd this happen?");
-        validCombo = false;
-        // Fall through to return an InvalidOperations. This will alert us to the
-        // unexpected case that needs fixing in builds without asserts.
-    }
+    // Here we're reinterpreting format as an unsized internalformat;
+    // these are the same in practice and there's no point in having the
+    // same code implemented twice.
+    TexInternalFormat effective =
+        EffectiveInternalFormatFromInternalFormatAndType(format, type);
+    bool validCombo = effective != LOCAL_GL_NONE;
 
     if (!validCombo)
         ErrorInvalidOperation("%s: invalid combination of format %s and type %s",
                               InfoFrom(func), WebGLContext::EnumName(format), WebGLContext::EnumName(type));
 
     return validCombo;
 }
 
@@ -1193,29 +1015,44 @@ WebGLContext::ValidateTexInputData(GLenu
     const char invalidTypedArray[] = "%s: invalid typed array type for given texture data type";
 
     // First, we check for packed types
     switch (type) {
     case LOCAL_GL_UNSIGNED_BYTE:
         validInput = (jsArrayType == -1 || jsArrayType == js::Scalar::Uint8);
         break;
 
+    case LOCAL_GL_BYTE:
+        validInput = (jsArrayType == -1 || jsArrayType == js::Scalar::Int8);
+        break;
+
     case LOCAL_GL_HALF_FLOAT:
     case LOCAL_GL_UNSIGNED_SHORT:
     case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4:
     case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1:
     case LOCAL_GL_UNSIGNED_SHORT_5_6_5:
         validInput = (jsArrayType == -1 || jsArrayType == js::Scalar::Uint16);
         break;
 
+    case LOCAL_GL_SHORT:
+        validInput = (jsArrayType == -1 || jsArrayType == js::Scalar::Int16);
+        break;
+
     case LOCAL_GL_UNSIGNED_INT:
     case LOCAL_GL_UNSIGNED_INT_24_8:
+    case LOCAL_GL_UNSIGNED_INT_2_10_10_10_REV:
+    case LOCAL_GL_UNSIGNED_INT_10F_11F_11F_REV:
+    case LOCAL_GL_UNSIGNED_INT_5_9_9_9_REV:
         validInput = (jsArrayType == -1 || jsArrayType == js::Scalar::Uint32);
         break;
 
+    case LOCAL_GL_INT:
+        validInput = (jsArrayType == -1 || jsArrayType == js::Scalar::Int32);
+        break;
+
     case LOCAL_GL_FLOAT:
         validInput = (jsArrayType == -1 || jsArrayType == js::Scalar::Float32);
         break;
 
     default:
         break;
     }
 
@@ -1309,32 +1146,29 @@ WebGLContext::ValidateTexImage(GLuint di
         if (!ValidateCompTexImageInternalFormat(internalFormat, func)) {
             return false;
         }
     } else if (IsCopyFunc(func)) {
         if (!ValidateCopyTexImageInternalFormat(internalFormat, func)) {
             return false;
         }
     } else if (format != internalFormat) {
-        /* WebGL and OpenGL ES 2.0 impose additional restrictions on the
-         * combinations of format, internalFormat, and type that can be
-         * used.  Formats and types that require additional extensions
-         * (e.g., GL_FLOAT requires GL_OES_texture_float) are filtered
-         * elsewhere.
-         */
-        ErrorInvalidOperation("%s: format does not match internalformat", info);
-        return false;
-    }
-
-    /* check internalFormat */
-    // TODO: Not sure if this is a bit of over kill.
-    if (BaseTexFormat(internalFormat) == LOCAL_GL_NONE) {
-        MOZ_ASSERT(false);
-        ErrorInvalidValue("%s:", info);
-        return false;
+        if (IsWebGL2()) {
+            // In WebGL2, it's OK to have internalformat != format if internalformat is the sized
+            // internal format corresponding to the (format, type) pair according to Table 3.2
+            // in the OpenGL ES 3.0.3 spec.
+            if (internalFormat != EffectiveInternalFormatFromInternalFormatAndType(format, type)) {
+                ErrorInvalidOperation("%s: internalformat does not match format and type", info);
+                return false;
+            }
+        } else {
+            // in WebGL 1, format must be equal to internalformat
+            ErrorInvalidOperation("%s: internalformat does not match format", info);
+            return false;
+        }
     }
 
     /* Check texture image size */
     if (!ValidateTexImageSize(texImageTarget, level, width, height, 0, func))
         return false;
 
     /* 5.14.8 Texture objects - WebGL Spec.
      *   "If an attempt is made to call these functions with no
--- a/dom/canvas/WebGLInternalFormatsTable.h
+++ b/dom/canvas/WebGLInternalFormatsTable.h
@@ -16,28 +16,28 @@
 //                    Effective int. fmt.     Unsized int. fmt.   Type
 WEBGL_INTERNAL_FORMAT(ALPHA8,                 ALPHA,              UNSIGNED_BYTE)
 WEBGL_INTERNAL_FORMAT(LUMINANCE8,             LUMINANCE,          UNSIGNED_BYTE)
 WEBGL_INTERNAL_FORMAT(LUMINANCE8_ALPHA8,      LUMINANCE_ALPHA,    UNSIGNED_BYTE)
 WEBGL_INTERNAL_FORMAT(RGB8,                   RGB,                UNSIGNED_BYTE)
 WEBGL_INTERNAL_FORMAT(RGBA4,                  RGBA,               UNSIGNED_SHORT_4_4_4_4)
 WEBGL_INTERNAL_FORMAT(RGB5_A1,                RGBA,               UNSIGNED_SHORT_5_5_5_1)
 WEBGL_INTERNAL_FORMAT(RGBA8,                  RGBA,               UNSIGNED_BYTE)
-WEBGL_INTERNAL_FORMAT(RGB10_A2,               RGB,                UNSIGNED_INT_2_10_10_10_REV)
+WEBGL_INTERNAL_FORMAT(RGB10_A2,               RGBA,               UNSIGNED_INT_2_10_10_10_REV)
 WEBGL_INTERNAL_FORMAT(DEPTH_COMPONENT16,      DEPTH_COMPONENT,    UNSIGNED_SHORT)
 WEBGL_INTERNAL_FORMAT(DEPTH_COMPONENT24,      DEPTH_COMPONENT,    UNSIGNED_INT)
 WEBGL_INTERNAL_FORMAT(R8,                     RED,                UNSIGNED_BYTE)
 WEBGL_INTERNAL_FORMAT(RG8,                    RG,                 UNSIGNED_BYTE)
 WEBGL_INTERNAL_FORMAT(R16F,                   RED,                HALF_FLOAT)
 WEBGL_INTERNAL_FORMAT(R32F,                   RED,                FLOAT)
 WEBGL_INTERNAL_FORMAT(RG16F,                  RG,                 HALF_FLOAT)
-WEBGL_INTERNAL_FORMAT(RG32F,                  RG,                 UNSIGNED_BYTE)
+WEBGL_INTERNAL_FORMAT(RG32F,                  RG,                 FLOAT)
 WEBGL_INTERNAL_FORMAT(R8I,                    RED_INTEGER,        BYTE)
 WEBGL_INTERNAL_FORMAT(R8UI,                   RED_INTEGER,        UNSIGNED_BYTE)
-WEBGL_INTERNAL_FORMAT(R16I,                   RED_INTEGER,        BYTE)
+WEBGL_INTERNAL_FORMAT(R16I,                   RED_INTEGER,        SHORT)
 WEBGL_INTERNAL_FORMAT(R16UI,                  RED_INTEGER,        UNSIGNED_SHORT)
 WEBGL_INTERNAL_FORMAT(R32I,                   RED_INTEGER,        INT)
 WEBGL_INTERNAL_FORMAT(R32UI,                  RED_INTEGER,        UNSIGNED_INT)
 WEBGL_INTERNAL_FORMAT(RG8I,                   RG_INTEGER,         BYTE)
 WEBGL_INTERNAL_FORMAT(RG8UI,                  RG_INTEGER,         UNSIGNED_BYTE)
 WEBGL_INTERNAL_FORMAT(RG16I,                  RG_INTEGER,         SHORT)
 WEBGL_INTERNAL_FORMAT(RG16UI,                 RG_INTEGER,         UNSIGNED_SHORT)
 WEBGL_INTERNAL_FORMAT(RG32I,                  RG_INTEGER,         INT)
--- a/dom/canvas/WebGLProgram.cpp
+++ b/dom/canvas/WebGLProgram.cpp
@@ -9,20 +9,20 @@
 #include "mozilla/dom/WebGLRenderingContextBinding.h"
 #include "GLContext.h"
 
 #include "MurmurHash3.h"
 
 using namespace mozilla;
 
 /** Takes an ASCII string like "foo[i]", turns it into "foo" and returns "[i]" in bracketPart
-  * 
+  *
   * \param string input/output: the string to split, becomes the string without the bracket part
   * \param bracketPart output: gets the bracket part.
-  * 
+  *
   * Notice that if there are multiple brackets like "foo[i].bar[j]", only the last bracket is split.
   */
 static bool SplitLastSquareBracket(nsACString& string, nsCString& bracketPart)
 {
     MOZ_ASSERT(bracketPart.IsEmpty(), "SplitLastSquareBracket must be called with empty bracketPart string");
 
     if (string.IsEmpty())
         return false;
@@ -212,16 +212,100 @@ WebGLProgram::GetUniformInfoForMappedIde
 
     WebGLUniformInfo info;
     mUniformInfoMap->Get(mutableName, &info);
     // we don't check if that Get failed, as if it did, it left info with default values
 
     return info;
 }
 
+bool
+WebGLProgram::UpdateInfo()
+{
+    mAttribMaxNameLength = 0;
+    for (size_t i = 0; i < mAttachedShaders.Length(); i++)
+        mAttribMaxNameLength = std::max(mAttribMaxNameLength, mAttachedShaders[i]->mAttribMaxNameLength);
+
+    GLint attribCount;
+    mContext->gl->fGetProgramiv(mGLName, LOCAL_GL_ACTIVE_ATTRIBUTES, &attribCount);
+
+    if (!mAttribsInUse.SetLength(mContext->mGLMaxVertexAttribs)) {
+        mContext->ErrorOutOfMemory("updateInfo: out of memory to allocate %d attribs", mContext->mGLMaxVertexAttribs);
+        return false;
+    }
+
+    for (size_t i = 0; i < mAttribsInUse.Length(); i++)
+        mAttribsInUse[i] = false;
+
+    nsAutoArrayPtr<char> nameBuf(new char[mAttribMaxNameLength]);
+
+    for (int i = 0; i < attribCount; ++i) {
+        GLint attrnamelen;
+        GLint attrsize;
+        GLenum attrtype;
+        mContext->gl->fGetActiveAttrib(mGLName, i, mAttribMaxNameLength, &attrnamelen, &attrsize, &attrtype, nameBuf);
+        if (attrnamelen > 0) {
+            GLint loc = mContext->gl->fGetAttribLocation(mGLName, nameBuf);
+            MOZ_ASSERT(loc >= 0, "major oops in managing the attributes of a WebGL program");
+            if (loc < mContext->mGLMaxVertexAttribs) {
+                mAttribsInUse[loc] = true;
+            } else {
+                mContext->GenerateWarning("program exceeds MAX_VERTEX_ATTRIBS");
+                return false;
+            }
+        }
+    }
+
+    // nsAutoPtr will delete old version first
+    mIdentifierMap = new CStringMap;
+    mIdentifierReverseMap = new CStringMap;
+    mUniformInfoMap = new CStringToUniformInfoMap;
+    for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
+        // Loop through ATTRIBUTES
+        for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) {
+            const WebGLMappedIdentifier& attrib = mAttachedShaders[i]->mAttributes[j];
+            mIdentifierMap->Put(attrib.original, attrib.mapped); // FORWARD MAPPING
+            mIdentifierReverseMap->Put(attrib.mapped, attrib.original); // REVERSE MAPPING
+        }
+
+        // Loop through UNIFORMS
+        for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) {
+            // Add the uniforms name mapping to mIdentifier[Reverse]Map
+            const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j];
+            mIdentifierMap->Put(uniform.original, uniform.mapped); // FOWARD MAPPING
+            mIdentifierReverseMap->Put(uniform.mapped, uniform.original); // REVERSE MAPPING
+
+            // Add uniform info to mUniformInfoMap
+            const WebGLUniformInfo& info = mAttachedShaders[i]->mUniformInfos[j];
+            mUniformInfoMap->Put(uniform.mapped, info);
+        }
+    }
+
+    mActiveAttribMap.clear();
+
+    GLint numActiveAttrs = 0;
+    mContext->gl->fGetProgramiv(mGLName, LOCAL_GL_ACTIVE_ATTRIBUTES, &numActiveAttrs);
+
+    // Spec says the maximum attrib name length is 256 chars, so this is
+    // sufficient to hold any attrib name.
+    char attrName[257];
+
+    GLint dummySize;
+    GLenum dummyType;
+    for (GLint i = 0; i < numActiveAttrs; i++) {
+        mContext->gl->fGetActiveAttrib(mGLName, i, 257, nullptr, &dummySize,
+                                       &dummyType, attrName);
+        GLint attrLoc = mContext->gl->fGetAttribLocation(mGLName, attrName);
+        MOZ_ASSERT(attrLoc >= 0);
+        mActiveAttribMap.insert(std::make_pair(attrLoc, nsCString(attrName)));
+    }
+
+    return true;
+}
+
 /* static */ uint64_t
 WebGLProgram::IdentifierHashFunction(const char *ident, size_t size)
 {
     uint64_t outhash[2];
     // NB: we use the x86 function everywhere, even though it's suboptimal perf
     // on x64.  They return different results; not sure if that's a requirement.
     MurmurHash3_x86_128(ident, size, 0, &outhash[0]);
     return outhash[0];
--- a/dom/canvas/WebGLStrongTypes.h
+++ b/dom/canvas/WebGLStrongTypes.h
@@ -289,31 +289,34 @@ STRONG_GLENUM_BEGIN(TexFormat)
     STRONG_GLENUM_VALUE(RED_INTEGER),     // 0x8D94
     STRONG_GLENUM_VALUE(RGB_INTEGER),     // 0x8D98
     STRONG_GLENUM_VALUE(RGBA_INTEGER),    // 0x8D99
 STRONG_GLENUM_END(TexFormat)
 
 STRONG_GLENUM_BEGIN(TexInternalFormat)
     STRONG_GLENUM_VALUE(NONE),
     STRONG_GLENUM_VALUE(DEPTH_COMPONENT),
+    STRONG_GLENUM_VALUE(RED),
     STRONG_GLENUM_VALUE(ALPHA),
     STRONG_GLENUM_VALUE(RGB),
     STRONG_GLENUM_VALUE(RGBA),
     STRONG_GLENUM_VALUE(LUMINANCE),
     STRONG_GLENUM_VALUE(LUMINANCE_ALPHA),
     STRONG_GLENUM_VALUE(ALPHA8),
     STRONG_GLENUM_VALUE(LUMINANCE8),
     STRONG_GLENUM_VALUE(LUMINANCE8_ALPHA8),
     STRONG_GLENUM_VALUE(RGB8),
     STRONG_GLENUM_VALUE(RGBA4),
     STRONG_GLENUM_VALUE(RGB5_A1),
     STRONG_GLENUM_VALUE(RGBA8),
     STRONG_GLENUM_VALUE(RGB10_A2),
     STRONG_GLENUM_VALUE(DEPTH_COMPONENT16),
     STRONG_GLENUM_VALUE(DEPTH_COMPONENT24),
+    STRONG_GLENUM_VALUE(RG),
+    STRONG_GLENUM_VALUE(RG_INTEGER),
     STRONG_GLENUM_VALUE(R8),
     STRONG_GLENUM_VALUE(RG8),
     STRONG_GLENUM_VALUE(R16F),
     STRONG_GLENUM_VALUE(R32F),
     STRONG_GLENUM_VALUE(RG16F),
     STRONG_GLENUM_VALUE(RG32F),
     STRONG_GLENUM_VALUE(R8I),
     STRONG_GLENUM_VALUE(R8UI),
@@ -367,16 +370,19 @@ STRONG_GLENUM_BEGIN(TexInternalFormat)
     STRONG_GLENUM_VALUE(RGBA8UI),
     STRONG_GLENUM_VALUE(RGB8UI),
     STRONG_GLENUM_VALUE(RGBA32I),
     STRONG_GLENUM_VALUE(RGB32I),
     STRONG_GLENUM_VALUE(RGBA16I),
     STRONG_GLENUM_VALUE(RGB16I),
     STRONG_GLENUM_VALUE(RGBA8I),
     STRONG_GLENUM_VALUE(RGB8I),
+    STRONG_GLENUM_VALUE(RED_INTEGER),
+    STRONG_GLENUM_VALUE(RGB_INTEGER),
+    STRONG_GLENUM_VALUE(RGBA_INTEGER),
     STRONG_GLENUM_VALUE(R8_SNORM),
     STRONG_GLENUM_VALUE(RG8_SNORM),
     STRONG_GLENUM_VALUE(RGB8_SNORM),
     STRONG_GLENUM_VALUE(RGBA8_SNORM),
     STRONG_GLENUM_VALUE(RGB10_A2UI),
 STRONG_GLENUM_END(TexInternalFormat)
 
 STRONG_GLENUM_BEGIN(FBTarget)
--- a/dom/canvas/WebGLTexelConversions.cpp
+++ b/dom/canvas/WebGLTexelConversions.cpp
@@ -320,25 +320,25 @@ public:
 
     bool Success() const {
         return mSuccess;
     }
 };
 
 } // end anonymous namespace
 
-void
+bool
 WebGLContext::ConvertImage(size_t width, size_t height, size_t srcStride, size_t dstStride,
                            const uint8_t* src, uint8_t *dst,
                            WebGLTexelFormat srcFormat, bool srcPremultiplied,
                            WebGLTexelFormat dstFormat, bool dstPremultiplied,
                            size_t dstTexelSize)
 {
     if (width <= 0 || height <= 0)
-        return;
+        return true;
 
     const bool FormatsRequireNoPremultiplicationOp =
         !HasAlpha(srcFormat) ||
         !HasColor(srcFormat) ||
         !HasColor(dstFormat);
 
     if (srcFormat == dstFormat &&
         (FormatsRequireNoPremultiplicationOp || srcPremultiplied == dstPremultiplied))
@@ -363,17 +363,23 @@ WebGLContext::ConvertImage(size_t width,
         ptrdiff_t dstStrideSigned(dstStride);
         ptrdiff_t dst_delta = mPixelStoreFlipY ? -dstStrideSigned : dstStrideSigned;
 
         while(ptr != src_end) {
             memcpy(dst_row, ptr, row_size);
             ptr += srcStride;
             dst_row += dst_delta;
         }
-        return;
+        return true;
+    }
+
+    if (srcFormat == WebGLTexelFormat::FormatNotSupportingAnyConversion ||
+        dstFormat == WebGLTexelFormat::FormatNotSupportingAnyConversion)
+    {
+        return false;
     }
 
     uint8_t* dstStart = dst;
     ptrdiff_t signedDstStride = dstStride;
     if (mPixelStoreFlipY) {
         dstStart = dst + (height - 1) * dstStride;
         signedDstStride = -signedDstStride;
     }
@@ -389,11 +395,13 @@ WebGLContext::ConvertImage(size_t width,
     converter.run(srcFormat, dstFormat, premultiplicationOp);
 
     if (!converter.Success()) {
         // the dst image may be left uninitialized, so we better not try to
         // continue even in release builds. This should never happen anyway,
         // and would be a bug in our code.
         NS_RUNTIMEABORT("programming mistake in WebGL texture conversions");
     }
+
+    return true;
 }
 
 } // end namespace mozilla
--- a/dom/canvas/WebGLTexelConversions.h
+++ b/dom/canvas/WebGLTexelConversions.h
@@ -227,25 +227,22 @@ inline GLenum
 GLFormatForTexelFormat(WebGLTexelFormat format) {
     switch (format) {
         case WebGLTexelFormat::R8:          return LOCAL_GL_LUMINANCE;
         case WebGLTexelFormat::A8:          return LOCAL_GL_ALPHA;
         case WebGLTexelFormat::RA8:         return LOCAL_GL_LUMINANCE_ALPHA;
         case WebGLTexelFormat::RGBA5551:    return LOCAL_GL_RGBA;
         case WebGLTexelFormat::RGBA4444:    return LOCAL_GL_RGBA;
         case WebGLTexelFormat::RGB565:      return LOCAL_GL_RGB;
-        case WebGLTexelFormat::D16:         return LOCAL_GL_DEPTH_COMPONENT;
         case WebGLTexelFormat::RGB8:        return LOCAL_GL_RGB;
         case WebGLTexelFormat::RGBA8:       return LOCAL_GL_RGBA;
         case WebGLTexelFormat::BGRA8:       return LOCAL_GL_BGRA;
         case WebGLTexelFormat::BGRX8:       return LOCAL_GL_BGR;
         case WebGLTexelFormat::R32F:        return LOCAL_GL_LUMINANCE;
         case WebGLTexelFormat::A32F:        return LOCAL_GL_ALPHA;
-        case WebGLTexelFormat::D32:         return LOCAL_GL_DEPTH_COMPONENT;
-        case WebGLTexelFormat::D24S8:       return LOCAL_GL_DEPTH_STENCIL;
         case WebGLTexelFormat::RA32F:       return LOCAL_GL_LUMINANCE_ALPHA;
         case WebGLTexelFormat::RGB32F:      return LOCAL_GL_RGB;
         case WebGLTexelFormat::RGBA32F:     return LOCAL_GL_RGBA;
         case WebGLTexelFormat::R16F:        return LOCAL_GL_LUMINANCE;
         case WebGLTexelFormat::A16F:        return LOCAL_GL_ALPHA;
         case WebGLTexelFormat::RA16F:       return LOCAL_GL_LUMINANCE_ALPHA;
         case WebGLTexelFormat::RGB16F:      return LOCAL_GL_RGB;
         case WebGLTexelFormat::RGBA16F:     return LOCAL_GL_RGBA;
@@ -261,27 +258,24 @@ inline size_t TexelBytesForFormat(WebGLT
         case WebGLTexelFormat::A8:
             return 1;
         case WebGLTexelFormat::RA8:
         case WebGLTexelFormat::RGBA5551:
         case WebGLTexelFormat::RGBA4444:
         case WebGLTexelFormat::RGB565:
         case WebGLTexelFormat::R16F:
         case WebGLTexelFormat::A16F:
-        case WebGLTexelFormat::D16:
             return 2;
         case WebGLTexelFormat::RGB8:
             return 3;
         case WebGLTexelFormat::RGBA8:
         case WebGLTexelFormat::BGRA8:
         case WebGLTexelFormat::BGRX8:
         case WebGLTexelFormat::R32F:
         case WebGLTexelFormat::A32F:
-        case WebGLTexelFormat::D32:
-        case WebGLTexelFormat::D24S8:
         case WebGLTexelFormat::RA16F:
             return 4;
         case WebGLTexelFormat::RGB16F:
             return 6;
         case WebGLTexelFormat::RGBA16F:
         case WebGLTexelFormat::RA32F:
             return 8;
         case WebGLTexelFormat::RGB32F:
--- a/dom/canvas/WebGLTexture.cpp
+++ b/dom/canvas/WebGLTexture.cpp
@@ -565,20 +565,27 @@ WebGLTexture::DoDeferredImageInitializat
     gl::GLContext* gl = mContext->gl;
     GLenum driverInternalFormat = LOCAL_GL_NONE;
     GLenum driverFormat = LOCAL_GL_NONE;
     GLenum driverType = LOCAL_GL_NONE;
     DriverFormatsFromEffectiveInternalFormat(gl, imageInfo.mEffectiveInternalFormat,
                                              &driverInternalFormat, &driverFormat, &driverType);
 
     mContext->GetAndFlushUnderlyingGLErrors();
-    gl->fTexImage2D(imageTarget.get(), level, driverInternalFormat,
-                    imageInfo.mWidth, imageInfo.mHeight,
-                    0, driverFormat, driverType,
-                    zeros);
+    if (mImmutable) {
+        gl->fTexSubImage2D(imageTarget.get(), level, 0, 0,
+                           imageInfo.mWidth, imageInfo.mHeight,
+                           driverFormat, driverType,
+                           zeros);
+    } else {
+        gl->fTexImage2D(imageTarget.get(), level, driverInternalFormat,
+                        imageInfo.mWidth, imageInfo.mHeight,
+                        0, driverFormat, driverType,
+                        zeros);
+    }
     GLenum error = mContext->GetAndFlushUnderlyingGLErrors();
     if (error) {
         // Should only be OUT_OF_MEMORY. Anyway, there's no good way to recover from this here.
         printf_stderr("Error: 0x%4x\n", error);
         MOZ_CRASH(); // errors on texture upload have been related to video memory exposure in the past.
     }
 
     SetImageDataStatus(imageTarget, level, WebGLImageDataStatus::InitializedImageData);
--- a/dom/canvas/WebGLTypes.h
+++ b/dom/canvas/WebGLTypes.h
@@ -93,37 +93,33 @@ MOZ_END_ENUM_CLASS(WebGLImageDataStatus)
  *  - all the formats accepted by WebGL.texImage2D, e.g. RGBA4444
  *  - additional formats provided by extensions, e.g. RGB32F
  *  - additional source formats, depending on browser details, used when uploading
  *    textures from DOM elements. See gfxImageSurface::Format().
  */
 MOZ_BEGIN_ENUM_CLASS(WebGLTexelFormat, int)
     // returned by SurfaceFromElementResultToImageSurface to indicate absence of image data
     None,
-    // dummy error code returned by GetWebGLTexelFormat in error cases,
-    // after assertion failure (so this never happens in debug builds)
-    BadFormat,
+    // common value for formats for which format conversions are not supported
+    FormatNotSupportingAnyConversion,
     // dummy pseudo-format meaning "use the other format".
     // For example, if SrcFormat=Auto and DstFormat=RGB8, then the source
     // is implicitly treated as being RGB8 itself.
     Auto,
     // 1-channel formats
     R8,
     A8,
-    D16, // WEBGL_depth_texture
-    D32, // WEBGL_depth_texture
     R16F, // OES_texture_half_float
     A16F, // OES_texture_half_float
     R32F, // OES_texture_float
     A32F, // OES_texture_float
     // 2-channel formats
     RA8,
     RA16F, // OES_texture_half_float
     RA32F, // OES_texture_float
-    D24S8, // WEBGL_depth_texture
     // 3-channel formats
     RGB8,
     BGRX8, // used for DOM elements. Source format only.
     RGB565,
     RGB16F, // OES_texture_half_float
     RGB32F, // OES_texture_float
     // 4-channel formats
     RGBA8,
--- a/dom/canvas/test/_webgl-conformance.ini
+++ b/dom/canvas/test/_webgl-conformance.ini
@@ -1,18 +1,17 @@
 # This is a GENERATED FILE. Do not edit it directly.
 # Regenerated it by using `python generate-wrapper-and-manifest.py`.
 # Mark skipped tests in mochitest-errata.ini.
 # Mark failing tests in mochi-single.html.
 
 [DEFAULT]
 skip-if = e10s || os == 'b2g' || ((os == 'linux') && (buildapp == 'b2g'))
 
-support-files = webgl-conformance/mochi-single.html
-                webgl-conformance/mochi-wrapper.css
+support-files = webgl-conformance/../webgl-mochitest/driver-info.js
                 webgl-conformance/always-fail.html
                 webgl-conformance/conformance/00_readme.txt
                 webgl-conformance/conformance/00_test_list.txt
                 webgl-conformance/conformance/LICENSE_CHROMIUM
                 webgl-conformance/conformance/attribs/00_test_list.txt
                 webgl-conformance/conformance/attribs/gl-enable-vertex-attrib.html
                 webgl-conformance/conformance/attribs/gl-vertex-attrib-zero-issues.html
                 webgl-conformance/conformance/attribs/gl-vertex-attrib.html
@@ -470,16 +469,18 @@ support-files = webgl-conformance/mochi-
                 webgl-conformance/conformance/uniforms/00_test_list.txt
                 webgl-conformance/conformance/uniforms/gl-uniform-arrays.html
                 webgl-conformance/conformance/uniforms/gl-uniform-bool.html
                 webgl-conformance/conformance/uniforms/gl-uniformmatrix4fv.html
                 webgl-conformance/conformance/uniforms/gl-unknown-uniform.html
                 webgl-conformance/conformance/uniforms/null-uniform-location.html
                 webgl-conformance/conformance/uniforms/uniform-location.html
                 webgl-conformance/conformance/uniforms/uniform-samplers-test.html
+                webgl-conformance/iframe-autoresize.js
+                webgl-conformance/mochi-single.html
                 webgl-conformance/resources/cors-util.js
                 webgl-conformance/resources/desktop-gl-constants.js
                 webgl-conformance/resources/js-test-pre.js
                 webgl-conformance/resources/js-test-style.css
                 webgl-conformance/resources/opengl_logo.jpg
                 webgl-conformance/resources/thunderbird-logo-64x64.png
                 webgl-conformance/resources/webgl-logo.png
                 webgl-conformance/resources/webgl-test-harness.js
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_always-fail.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_always-fail.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?always-fail.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?always-fail.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__attribs__gl-enable-vertex-attrib.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__attribs__gl-enable-vertex-attrib.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/attribs/gl-enable-vertex-attrib.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/attribs/gl-enable-vertex-attrib.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__attribs__gl-vertex-attrib-zero-issues.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__attribs__gl-vertex-attrib-zero-issues.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/attribs/gl-vertex-attrib-zero-issues.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/attribs/gl-vertex-attrib-zero-issues.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__attribs__gl-vertex-attrib.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__attribs__gl-vertex-attrib.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/attribs/gl-vertex-attrib.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/attribs/gl-vertex-attrib.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__attribs__gl-vertexattribpointer-offsets.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__attribs__gl-vertexattribpointer-offsets.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/attribs/gl-vertexattribpointer-offsets.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/attribs/gl-vertexattribpointer-offsets.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__attribs__gl-vertexattribpointer.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__attribs__gl-vertexattribpointer.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/attribs/gl-vertexattribpointer.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/attribs/gl-vertexattribpointer.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__buffer-bind-test.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__buffer-bind-test.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/buffers/buffer-bind-test.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/buffers/buffer-bind-test.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__buffer-data-array-buffer.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__buffer-data-array-buffer.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/buffers/buffer-data-array-buffer.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/buffers/buffer-data-array-buffer.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__index-validation-copies-indices.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__index-validation-copies-indices.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/buffers/index-validation-copies-indices.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/buffers/index-validation-copies-indices.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__index-validation-crash-with-buffer-sub-data.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__index-validation-crash-with-buffer-sub-data.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/buffers/index-validation-crash-with-buffer-sub-data.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/buffers/index-validation-crash-with-buffer-sub-data.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__index-validation-verifies-too-many-indices.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__index-validation-verifies-too-many-indices.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/buffers/index-validation-verifies-too-many-indices.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/buffers/index-validation-verifies-too-many-indices.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__index-validation-with-resized-buffer.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__index-validation-with-resized-buffer.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/buffers/index-validation-with-resized-buffer.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/buffers/index-validation-with-resized-buffer.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__index-validation.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__buffers__index-validation.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/buffers/index-validation.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/buffers/index-validation.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__buffer-offscreen-test.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__buffer-offscreen-test.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/canvas/buffer-offscreen-test.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/canvas/buffer-offscreen-test.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__buffer-preserve-test.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__buffer-preserve-test.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/canvas/buffer-preserve-test.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/canvas/buffer-preserve-test.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__canvas-test.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__canvas-test.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/canvas/canvas-test.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/canvas/canvas-test.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__canvas-zero-size.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__canvas-zero-size.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/canvas/canvas-zero-size.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/canvas/canvas-zero-size.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__drawingbuffer-static-canvas-test.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__drawingbuffer-static-canvas-test.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/canvas/drawingbuffer-static-canvas-test.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/canvas/drawingbuffer-static-canvas-test.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__drawingbuffer-test.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__drawingbuffer-test.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/canvas/drawingbuffer-test.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/canvas/drawingbuffer-test.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__viewport-unchanged-upon-resize.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__canvas__viewport-unchanged-upon-resize.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/canvas/viewport-unchanged-upon-resize.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/canvas/viewport-unchanged-upon-resize.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__constants.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__constants.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/context/constants.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/context/constants.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__context-attributes-alpha-depth-stencil-antialias.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__context-attributes-alpha-depth-stencil-antialias.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/context/context-attributes-alpha-depth-stencil-antialias.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/context/context-attributes-alpha-depth-stencil-antialias.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__context-lost-restored.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__context-lost-restored.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/context/context-lost-restored.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/context/context-lost-restored.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__context-lost.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__context-lost.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/context/context-lost.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/context/context-lost.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__context-type-test.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__context-type-test.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/context/context-type-test.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/context/context-type-test.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__incorrect-context-object-behaviour.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__incorrect-context-object-behaviour.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/context/incorrect-context-object-behaviour.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/context/incorrect-context-object-behaviour.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__methods.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__methods.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/context/methods.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/context/methods.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__premultiplyalpha-test.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__premultiplyalpha-test.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/context/premultiplyalpha-test.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/context/premultiplyalpha-test.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__resource-sharing-test.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__context__resource-sharing-test.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/context/resource-sharing-test.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/context/resource-sharing-test.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__ext-sRGB.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__ext-sRGB.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/extensions/ext-sRGB.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/extensions/ext-sRGB.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__ext-shader-texture-lod.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__ext-shader-texture-lod.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/extensions/ext-shader-texture-lod.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/extensions/ext-shader-texture-lod.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__ext-texture-filter-anisotropic.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__ext-texture-filter-anisotropic.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/extensions/ext-texture-filter-anisotropic.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/extensions/ext-texture-filter-anisotropic.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__oes-standard-derivatives.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__oes-standard-derivatives.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/extensions/oes-standard-derivatives.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/extensions/oes-standard-derivatives.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__oes-texture-float.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__oes-texture-float.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/extensions/oes-texture-float.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/extensions/oes-texture-float.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__oes-vertex-array-object.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__oes-vertex-array-object.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/extensions/oes-vertex-array-object.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/extensions/oes-vertex-array-object.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__webgl-compressed-texture-etc1.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__webgl-compressed-texture-etc1.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/extensions/webgl-compressed-texture-etc1.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/extensions/webgl-compressed-texture-etc1.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__webgl-compressed-texture-s3tc.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__webgl-compressed-texture-s3tc.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/extensions/webgl-compressed-texture-s3tc.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/extensions/webgl-compressed-texture-s3tc.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__webgl-debug-renderer-info.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__webgl-debug-renderer-info.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/extensions/webgl-debug-renderer-info.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/extensions/webgl-debug-renderer-info.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__webgl-debug-shaders.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__extensions__webgl-debug-shaders.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/extensions/webgl-debug-shaders.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/extensions/webgl-debug-shaders.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-abs.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-abs.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-abs.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-abs.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-acos.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-acos.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-acos.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-acos.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-asin.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-asin.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-asin.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-asin.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-atan-xy.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-atan-xy.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-atan-xy.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-atan-xy.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-atan.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-atan.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-atan.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-atan.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-ceil.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-ceil.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-ceil.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-ceil.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-clamp-float.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-clamp-float.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-clamp-float.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-clamp-float.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-clamp-gentype.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-clamp-gentype.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-clamp-gentype.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-clamp-gentype.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-cos.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-cos.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-cos.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-cos.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-cross.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-cross.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-cross.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-cross.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-distance.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-distance.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-distance.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-distance.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-dot.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-dot.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-dot.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-dot.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-faceforward.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-faceforward.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-faceforward.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-faceforward.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-floor.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-floor.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-floor.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-floor.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-fract.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-fract.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-fract.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-fract.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-length.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-length.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-length.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-length.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-max-float.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-max-float.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-max-float.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-max-float.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-max-gentype.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-max-gentype.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-max-gentype.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-max-gentype.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-min-float.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-min-float.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-min-float.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-min-float.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-min-gentype.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-min-gentype.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-min-gentype.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-min-gentype.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mix-float.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mix-float.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-mix-float.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-mix-float.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mix-gentype.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mix-gentype.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-mix-gentype.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-mix-gentype.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mod-float.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mod-float.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-mod-float.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-mod-float.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mod-gentype.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mod-gentype.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-mod-gentype.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-mod-gentype.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-normalize.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-normalize.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-normalize.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-normalize.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-reflect.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-reflect.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-reflect.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-reflect.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-sign.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-sign.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-sign.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-sign.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-sin.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-sin.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-sin.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-sin.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-smoothstep-float.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-smoothstep-float.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-smoothstep-float.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-smoothstep-float.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-smoothstep-gentype.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-smoothstep-gentype.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-smoothstep-gentype.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-smoothstep-gentype.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-step-float.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-step-float.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-step-float.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-step-float.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-step-gentype.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-step-gentype.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function-step-gentype.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function-step-gentype.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/functions/glsl-function.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/functions/glsl-function.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_float.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_float.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/add_int_float.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/add_int_float.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_mat2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_mat2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/add_int_mat2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/add_int_mat2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_mat3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_mat3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/add_int_mat3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/add_int_mat3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_mat4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_mat4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/add_int_mat4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/add_int_mat4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/add_int_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/add_int_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/add_int_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/add_int_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/add_int_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/add_int_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_ivec2_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_ivec2_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/add_ivec2_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/add_ivec2_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_ivec3_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_ivec3_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/add_ivec3_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/add_ivec3_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_ivec4_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_ivec4_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/add_ivec4_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/add_ivec4_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_int_to_float.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_int_to_float.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/assign_int_to_float.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/assign_int_to_float.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_ivec2_to_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_ivec2_to_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/assign_ivec2_to_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/assign_ivec2_to_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_ivec3_to_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_ivec3_to_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/assign_ivec3_to_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/assign_ivec3_to_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_ivec4_to_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_ivec4_to_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/assign_ivec4_to_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/assign_ivec4_to_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__construct_struct.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__construct_struct.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/construct_struct.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/construct_struct.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_float.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_float.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/divide_int_float.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/divide_int_float.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_mat2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_mat2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/divide_int_mat2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/divide_int_mat2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_mat3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_mat3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/divide_int_mat3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/divide_int_mat3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_mat4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_mat4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/divide_int_mat4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/divide_int_mat4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/divide_int_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/divide_int_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/divide_int_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/divide_int_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/divide_int_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/divide_int_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_ivec2_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_ivec2_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/divide_ivec2_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/divide_ivec2_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_ivec3_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_ivec3_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/divide_ivec3_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/divide_ivec3_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_ivec4_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_ivec4_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/divide_ivec4_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/divide_ivec4_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_int_float.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_int_float.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/equal_int_float.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/equal_int_float.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_ivec2_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_ivec2_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/equal_ivec2_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/equal_ivec2_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_ivec3_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_ivec3_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/equal_ivec3_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/equal_ivec3_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_ivec4_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_ivec4_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/equal_ivec4_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/equal_ivec4_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_int_float.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_int_float.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/function_int_float.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/function_int_float.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_ivec2_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_ivec2_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/function_ivec2_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/function_ivec2_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_ivec3_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_ivec3_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/function_ivec3_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/function_ivec3_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_ivec4_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_ivec4_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/function_ivec4_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/function_ivec4_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__greater_than.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__greater_than.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/greater_than.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/greater_than.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__greater_than_equal.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__greater_than_equal.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/greater_than_equal.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/greater_than_equal.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__less_than.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__less_than.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/less_than.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/less_than.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__less_than_equal.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__less_than_equal.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/less_than_equal.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/less_than_equal.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_float.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_float.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/multiply_int_float.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/multiply_int_float.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_mat2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_mat2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/multiply_int_mat2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/multiply_int_mat2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_mat3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_mat3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/multiply_int_mat3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/multiply_int_mat3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_mat4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_mat4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/multiply_int_mat4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/multiply_int_mat4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/multiply_int_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/multiply_int_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/multiply_int_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/multiply_int_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/multiply_int_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/multiply_int_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_ivec2_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_ivec2_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/multiply_ivec2_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/multiply_ivec2_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_ivec3_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_ivec3_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/multiply_ivec3_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/multiply_ivec3_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_ivec4_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_ivec4_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/multiply_ivec4_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/multiply_ivec4_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_int_float.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_int_float.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/not_equal_int_float.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/not_equal_int_float.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_ivec2_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_ivec2_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/not_equal_ivec2_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/not_equal_ivec2_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_ivec3_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_ivec3_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/not_equal_ivec3_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/not_equal_ivec3_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_ivec4_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_ivec4_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/not_equal_ivec4_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/not_equal_ivec4_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_float.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_float.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/subtract_int_float.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/subtract_int_float.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_mat2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_mat2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/subtract_int_mat2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/subtract_int_mat2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_mat3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_mat3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/subtract_int_mat3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/subtract_int_mat3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_mat4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_mat4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/subtract_int_mat4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/subtract_int_mat4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/subtract_int_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/subtract_int_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/subtract_int_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/subtract_int_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/subtract_int_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/subtract_int_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_ivec2_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_ivec2_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/subtract_ivec2_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/subtract_ivec2_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_ivec3_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_ivec3_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/subtract_ivec3_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/subtract_ivec3_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_ivec4_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_ivec4_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/subtract_ivec4_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/subtract_ivec4_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_int_float.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_int_float.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/ternary_int_float.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/ternary_int_float.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_ivec2_vec2.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_ivec2_vec2.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/ternary_ivec2_vec2.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/ternary_ivec2_vec2.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_ivec3_vec3.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_ivec3_vec3.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/ternary_ivec3_vec3.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/ternary_ivec3_vec3.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_ivec4_vec4.vert.html
+++ b/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_ivec4_vec4.vert.html
@@ -1,16 +1,20 @@
 <!DOCTYPE HTML>
-<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<meta http-equiv='content-type' content='text/html; charset=utf-8' />
 <html>
 <head>
-<title>
-Mochitest wrapper for WebGL Conformance Test Suite tests
-</title>
-<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-<link rel="stylesheet" type="text/css" href="../mochi-wrapper.css"/>
+  <title>
+  Mochitest wrapper for WebGL Conformance Test Suite tests
+  </title>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
+  <script src='../iframe-autoresize.js'></script>
 </head>
 <body>
-<iframe src='../mochi-single.html?conformance/glsl/implicit/ternary_ivec4_vec4.vert.html'>
-</iframe>
+  <iframe id='mochi-single' style='border:none' width='100%' scrolling='no'
+          src='../mochi-single.html?conformance/glsl/implicit/ternary_ivec4_vec4.vert.html'>
+  </iframe>
+  <script>
+    IFrameAutoresize.StartById('mochi-single', false);
+  </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conformance/_wrappers/test_conformance__glsl__misc__attrib-location-length-limits.html
<