Merge mozilla-central and mozilla-inbound
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 10 Jun 2011 16:07:54 -0400
changeset 70883 28217403cd02
parent 70882 24b3cd3c8ed7 (current diff)
parent 70865 84636464bba8 (diff)
child 70884 fbeb460473f5
child 70903 776b0b91568e
push id20435
push usereakhgari@mozilla.com
push dateFri, 10 Jun 2011 20:08:22 +0000
treeherdermozilla-central@28217403cd02 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone7.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge mozilla-central and mozilla-inbound
gfx/angle/angle-makefiles.patch
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -292,19 +292,16 @@ WebGLContext::GetCanvas(nsIDOMHTMLCanvas
 
 //
 // nsICanvasRenderingContextInternal
 //
 
 NS_IMETHODIMP
 WebGLContext::SetCanvasElement(nsHTMLCanvasElement* aParentCanvas)
 {
-    if (aParentCanvas && !SafeToCreateCanvas3DContext(aParentCanvas))
-        return NS_ERROR_FAILURE;
-
     mCanvasElement = aParentCanvas;
 
     return NS_OK;
 }
 
 static bool
 GetBoolFromPropertyBag(nsIPropertyBag *bag, const char *propName, bool *boolResult)
 {
@@ -359,16 +356,18 @@ WebGLContext::SetContextOptions(nsIPrope
 
     mOptions = newOpts;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
 {
+    /*** early success return cases ***/
+  
     if (mCanvasElement) {
         HTMLCanvasElement()->InvalidateCanvas();
     }
 
     if (gl && mWidth == width && mHeight == height)
         return NS_OK;
 
     // Zero-sized surfaces can cause problems.
@@ -384,33 +383,58 @@ WebGLContext::SetDimensions(PRInt32 widt
     {
         // everything's good, we're done here
         mWidth = width;
         mHeight = height;
         mResetLayer = PR_TRUE;
         return NS_OK;
     }
 
+    /*** end of early success return cases ***/
+
     ScopedGfxFeatureReporter reporter("WebGL");
 
+    // At this point we know that the old context is not going to survive, even though we still don't
+    // know if creating the new context will succeed.
+    DestroyResourcesAndContext();
+
+    // Get some prefs for some preferred/overriden things
+    nsCOMPtr<nsIPrefBranch> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
+    NS_ENSURE_TRUE(prefService != nsnull, NS_ERROR_FAILURE);
+
+    PRBool forceOSMesa = PR_FALSE;
+    PRBool preferEGL = PR_FALSE;
+    PRBool preferOpenGL = PR_FALSE;
+    PRBool forceEnabled = PR_FALSE;
+    PRBool disabled = PR_FALSE;
+    PRBool verbose = PR_FALSE;
+
+    prefService->GetBoolPref("webgl.force_osmesa", &forceOSMesa);
+    prefService->GetBoolPref("webgl.prefer-egl", &preferEGL);
+    prefService->GetBoolPref("webgl.prefer-native-gl", &preferOpenGL);
+    prefService->GetBoolPref("webgl.force-enabled", &forceEnabled);
+    prefService->GetBoolPref("webgl.disabled", &disabled);
+    prefService->GetBoolPref("webgl.verbose", &verbose);
+
+    if (disabled)
+        return NS_ERROR_FAILURE;
+
+    mVerbose = verbose;
+
     // We're going to create an entirely new context.  If our
     // generation is not 0 right now (that is, if this isn't the first
     // context we're creating), we may have to dispatch a context lost
     // event.
 
     // If incrementing the generation would cause overflow,
     // don't allow it.  Allowing this would allow us to use
     // resource handles created from older context generations.
     if (!(mGeneration+1).valid())
         return NS_ERROR_FAILURE; // exit without changing the value of mGeneration
 
-    // We're going to recreate our context, so make sure we clean up
-    // after ourselves.
-    DestroyResourcesAndContext();
-
     gl::ContextFormat format(gl::ContextFormat::BasicRGBA32);
     if (mOptions.depth) {
         format.depth = 24;
         format.minDepth = 16;
     }
 
     if (mOptions.stencil) {
         format.stencil = 8;
@@ -423,32 +447,16 @@ WebGLContext::SetDimensions(PRInt32 widt
         format.red = 5;
         format.green = 6;
         format.blue = 5;
 
         format.alpha = 0;
         format.minAlpha = 0;
     }
 
-    nsCOMPtr<nsIPrefBranch> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
-    NS_ENSURE_TRUE(prefService != nsnull, NS_ERROR_FAILURE);
-
-    PRBool verbose = PR_FALSE;
-    prefService->GetBoolPref("webgl.verbose", &verbose);
-    mVerbose = verbose;
-
-    // Get some prefs for some preferred/overriden things
-    PRBool forceOSMesa = PR_FALSE;
-    PRBool preferEGL = PR_FALSE;
-    PRBool preferOpenGL = PR_FALSE;
-    PRBool forceEnabled = PR_FALSE;
-    prefService->GetBoolPref("webgl.force_osmesa", &forceOSMesa);
-    prefService->GetBoolPref("webgl.prefer-egl", &preferEGL);
-    prefService->GetBoolPref("webgl.prefer-native-gl", &preferOpenGL);
-    prefService->GetBoolPref("webgl.force-enabled", &forceEnabled);
     if (PR_GetEnv("MOZ_WEBGL_PREFER_EGL")) {
         preferEGL = PR_TRUE;
     }
 
     // Ask GfxInfo about what we should use
     PRBool useOpenGL = PR_TRUE;
     PRBool useANGLE = PR_TRUE;
 
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -443,17 +443,16 @@ protected:
         WebGLExtensionID_Max
     };
     nsCOMPtr<nsIWebGLExtension> mEnabledExtensions[WebGLExtensionID_Max];
     PRBool IsExtensionEnabled(WebGLExtensionID ext) const {
         NS_ABORT_IF_FALSE(ext >= 0 && ext < WebGLExtensionID_Max, "bogus index!");
         return mEnabledExtensions[ext] != nsnull;
     }
 
-    PRBool SafeToCreateCanvas3DContext(nsHTMLCanvasElement *canvasElement);
     PRBool InitAndValidateGL();
     PRBool ValidateBuffers(PRInt32* maxAllowedCount, const char *info);
     PRBool ValidateCapabilityEnum(WebGLenum cap, const char *info);
     PRBool ValidateBlendEquationEnum(WebGLenum cap, const char *info);
     PRBool ValidateBlendFuncDstEnum(WebGLenum mode, const char *info);
     PRBool ValidateBlendFuncSrcEnum(WebGLenum mode, const char *info);
     PRBool ValidateBlendFuncEnumsCompatibility(WebGLenum sfactor, WebGLenum dfactor, const char *info);
     PRBool ValidateTextureTargetEnum(WebGLenum target, const char *info);
--- a/content/canvas/src/WebGLContextUtils.cpp
+++ b/content/canvas/src/WebGLContextUtils.cpp
@@ -62,148 +62,16 @@
 
 #if 0
 #include "nsIContentURIGrouper.h"
 #include "nsIContentPrefService.h"
 #endif
 
 using namespace mozilla;
 
-PRBool
-WebGLContext::SafeToCreateCanvas3DContext(nsHTMLCanvasElement *canvasElement)
-{
-    nsresult rv;
-
-    // first see if we're a chrome context
-    PRBool is_caller_chrome = PR_FALSE;
-    nsCOMPtr<nsIScriptSecurityManager> ssm =
-        do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-
-    rv = ssm->SubjectPrincipalIsSystem(&is_caller_chrome);
-    if (NS_SUCCEEDED(rv) && is_caller_chrome)
-        return PR_TRUE;
-
-    // not chrome? check pref.
-
-    // first check our global pref
-    nsCOMPtr<nsIPrefBranch> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-
-    PRBool disabled = PR_FALSE;
-    rv = prefService->GetBoolPref("webgl.disabled", &disabled);
-    if (NS_SUCCEEDED(rv) && !disabled) {
-        // the all-sites pref was set, we're good to go
-        return PR_TRUE;
-    }
-
-#if 0
-    // otherwise we'll check content prefs
-    nsCOMPtr<nsIContentPrefService> cpsvc = do_GetService("@mozilla.org/content-pref/service;1", &rv);
-    if (NS_FAILED(rv)) {
-        LogMessage("Canvas 3D: Failed to get Content Pref service, can't verify that canvas3d is ok for this site!");
-        return PR_FALSE;
-    }
-
-    // grab our content URI
-    nsCOMPtr<nsIURI> contentURI;
-
-    nsCOMPtr<nsIPrincipal> principal;
-    rv = ssm->GetSubjectPrincipal(getter_AddRefs(principal));
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-
-    if (!principal) {
-        // seriously? no script executing, but not the system principal?
-        return PR_FALSE;
-    }
-    rv = principal->GetURI(getter_AddRefs(contentURI));
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-
-    // our pref is 'webgl.enabled'
-    nsCOMPtr<nsIVariant> val;
-    rv = cpsvc->GetPref(contentURI, NS_LITERAL_STRING("webgl.enabled"), getter_AddRefs(val));
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-
-    PRInt32 iv;
-    rv = val->GetAsInt32(&iv);
-    if (NS_SUCCEEDED(rv)) {
-        // 1 means "yes, allowed"
-        if (iv == 1)
-            return PR_TRUE;
-
-        // -1 means "no, don't ask me again"
-        if (iv == -1)
-            return PR_FALSE;
-
-        // otherwise, we'll throw an event and maybe ask the user
-    }
-
-    // grab the document that we can use to create the event
-    nsCOMPtr<nsIDOMNode> node = do_QueryInterface(canvasElement);
-    nsCOMPtr<nsIDOMDocument> domDoc;
-    rv = node->GetOwnerDocument(getter_AddRefs(domDoc));
-
-    /*
-    // figure out where to throw the event.  we just go for the outermost
-    // document.  ideally, I want to throw the event to the <browser> if one exists,
-    // otherwise the topmost document, but that's more work than I want to deal with.
-    nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
-    while (doc->GetParentDocument())
-        doc = doc->GetParentDocument();
-    */
-
-    // set up the event
-    nsCOMPtr<nsIDOMDocumentEvent> docEvent = do_QueryInterface(domDoc);
-    NS_ENSURE_TRUE(docEvent, PR_FALSE);
-
-    nsCOMPtr<nsIDOMEvent> eventBase;
-    rv = docEvent->CreateEvent(NS_LITERAL_STRING("DataContainerEvent"), getter_AddRefs(eventBase));
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-
-    rv = eventBase->InitEvent(NS_LITERAL_STRING("Canvas3DContextRequest"), PR_TRUE, PR_TRUE);
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-
-    nsCOMPtr<nsIDOMDataContainerEvent> event = do_QueryInterface(eventBase);
-    nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(eventBase);
-    NS_ENSURE_TRUE(event && privateEvent, PR_FALSE);
-
-    // mark it as trusted, so that it'll bubble upwards into chrome
-    privateEvent->SetTrusted(PR_TRUE);
-
-    // set some extra data on the event
-    nsCOMPtr<nsIContentURIGrouper> grouper = do_GetService("@mozilla.org/content-pref/hostname-grouper;1", &rv);
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-
-    nsAutoString group;
-    rv = grouper->Group(contentURI, group);
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-
-    nsCOMPtr<nsIWritableVariant> groupVariant = do_CreateInstance(NS_VARIANT_CONTRACTID);
-    nsCOMPtr<nsIWritableVariant> uriVariant = do_CreateInstance(NS_VARIANT_CONTRACTID);
-
-    groupVariant->SetAsAString(group);
-    uriVariant->SetAsISupports(contentURI);
-
-    rv = event->SetData(NS_LITERAL_STRING("group"), groupVariant);
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-
-    rv = event->SetData(NS_LITERAL_STRING("uri"), uriVariant);
-    NS_ENSURE_SUCCESS(rv, PR_FALSE);
-
-    // our target...
-    nsCOMPtr<nsIDOMEventTarget> targ = do_QueryInterface(canvasElement);
-
-    // and go.
-    PRBool defaultActionEnabled;
-    targ->DispatchEvent(event, &defaultActionEnabled);
-#endif
-
-    return PR_FALSE;
-}
-
 void
 WebGLContext::LogMessage(const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
 
     LogMessage(fmt, ap);
 
--- a/content/canvas/test/webgl/test_webgl_conformance_test_suite.html
+++ b/content/canvas/test/webgl/test_webgl_conformance_test_suite.html
@@ -229,17 +229,17 @@ function start() {
       this.currentPage = null;
       this.displayStats();
     }
   };
 
   Reporter.prototype.finishedTestSuite = function() {
       for (var i = 0; i < testsExpectedToFail.length; ++i)
         if (testsSuccessful.indexOf(testsExpectedToFail[i]) != -1)
-          ok(false, 'Test expected to fail, but passed: ' + testsExpectedToFail[i]);
+          todo(true, 'Test expected to fail, but passed: ' + testsExpectedToFail[i]);
       statusTextNode.textContent = 'Finished';
       SimpleTest.finish();
   }
 
   Reporter.prototype.reportFunc = function(type, msg, success) {
     switch (type) {
       case reportType.ADD_PAGE:
         return this.addPage(msg);
@@ -358,16 +358,23 @@ function start() {
     failingTestsFilename = 'failing_tests_linux.txt';
   else if (kIsMac)
     failingTestsFilename = 'failing_tests_mac.txt';
 
   var testsExpectedToFail = loadTextFileSynchronous(failingTestsFilename)
                             .replace(/\r/g, '') // convert to unix line breaks
                             .split('\n');
 
+  if (kIsWindows && !kIsWindowsVistaOrHigher) {
+    testsExpectedToFail.push('conformance/framebuffer-object-attachment.html'); // NVIDIA 190.42 doesnt support DEPTH_STENCIL
+    testsExpectedToFail.push('conformance/gl-get-active-attribute.html'); // bug in NVIDIA 190.42, fixed in newer drivers
+    testsExpectedToFail.push('conformance/gl-uniform-bool.html'); // bug in NVIDIA 190.42, fixed in newer drivers
+    testsExpectedToFail.push('conformance/tex-image-and-sub-image-2d-with-array-buffer-view.html'); // ???
+  }
+
   var testsToIgnore = [];
 
   var testsSuccessful = [];
 
   runTestSuite();
 }
 
 </script>
--- a/content/events/test/Makefile.in
+++ b/content/events/test/Makefile.in
@@ -55,19 +55,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug288392.html \
 		test_bug299673-1.html \
 		test_bug299673-2.html \
 		     bug299673.js \
 		test_bug322588.html \
 		     bug322588-popup.html \
 		test_bug328885.html \
 		test_bug336682_1.html \
-		test_bug336682_2.xul \
 		test_bug336682.js \
-		test_bug350471.xul \
 		test_bug367781.html \
 		test_bug368835.html \
 		test_bug379120.html \
 		test_bug391568.xhtml \
 		test_bug402089.html \
 		test_bug405632.html \
 		test_bug409604.html \
 		test_bug412567.html \
@@ -87,17 +85,16 @@ include $(topsrcdir)/config/rules.mk
 		test_bug508906.html \
 		test_bug517851.html \
 		test_bug534833.html \
 		test_bug545268.html \
 		test_bug547996-1.html \
 		test_bug547996-2.xhtml \
 		test_bug556493.html \
 		test_bug574663.html \
-		test_bug586961.xul \
 		test_clickevent_on_input.html \
 		test_bug593959.html \
 		test_bug591815.html \
 		test_bug605242.html \
 		test_bug613634.html \
 		test_bug607464.html \
 		test_bug624127.html \
 		test_bug650493.html \
@@ -119,16 +116,20 @@ endif
 # bug 565245
 ifneq (Linux,$(OS_ARCH))
 _TEST_FILES += \
 		test_bug493251.html \
 		$(NULL)
 endif
 
 _CHROME_FILES = \
+		test_bug336682_2.xul \
+		test_bug336682.js \
+		test_bug350471.xul \
+		test_bug586961.xul \
 		test_bug415498.xul \
 		bug415498-doc1.html \
 		bug415498-doc2.html \
 		bug602962.xul \
 		test_bug602962.xul \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
--- a/content/events/test/test_bug336682_2.xul
+++ b/content/events/test/test_bug336682_2.xul
@@ -1,26 +1,26 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 <!--
 Bug 336682: online/offline events tests.
 
 Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/licenses/publicdomain/
 -->
 <window title="Mozilla Bug 336682"
   onoffline="trace('lt;body onoffline=...'); windowOnoffline(this, event)"
   ononline="trace('lt;body ononline=...'); windowOnonline(this, event)"
 
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
-  <script type="application/javascript" src="/MochiKit/packed.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>      
+  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=336682">
 Mozilla Bug 336682 (online/offline events)</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 </body>
--- a/content/events/test/test_bug350471.xul
+++ b/content/events/test/test_bug350471.xul
@@ -1,21 +1,21 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=350471
 -->
 <window title="Mozilla Bug 350471"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <title>Test for Bug 350471</title>
-  <script type="application/javascript" src="/MochiKit/packed.js" />
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js" />
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 <body  xmlns="http://www.w3.org/1999/xhtml">
   <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=350471">Mozilla Bug 350471</a>
 
   <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 </body>
 
--- a/content/events/test/test_bug586961.xul
+++ b/content/events/test/test_bug586961.xul
@@ -1,21 +1,21 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=586961
 -->
 <window title="Mozilla Bug 586961"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <title>Test for Bug 586961</title>
-  <script type="application/javascript" src="/MochiKit/packed.js" />
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js" />
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 <body  xmlns="http://www.w3.org/1999/xhtml">
   <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=586961">Mozilla Bug 586961</a>
 
   <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 </body>
 
--- a/content/xbl/test/Makefile.in
+++ b/content/xbl/test/Makefile.in
@@ -42,28 +42,24 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = content/xbl/test
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES =	\
-		test_bug296375.xul \
 		test_bug310107.html \
 		bug310107-resource.xhtml \
 		test_bug366770.html \
 		test_bug371724.xhtml \
 		test_bug372769.xhtml \
-		test_bug378518.xul \
 		test_bug378866.xhtml \
 		test_bug397934.xhtml \
 		test_bug389322.xhtml \
-		test_bug398135.xul \
-		test_bug398492.xul \
 		test_bug400705.xhtml \
 		test_bug401907.xhtml \
 		test_bug403162.xhtml \
 		test_bug379959.html \
 		file_bug379959_data.html \
 		file_bug379959_cross.html \
 		file_bug379959_xbl.xml \
 		test_bug468210.xhtml \
@@ -73,10 +69,21 @@ include $(topsrcdir)/config/rules.mk
 		test_bug526178.xhtml \
 		test_bug542406.xhtml \
 		test_bug591198.html \
 		file_bug591198_xbl.xml \
 		file_bug591198_inner.html \
 		test_bug639338.xhtml \
 		$(NULL)
 
+_CHROME_FILES = \
+		test_bug296375.xul \
+		test_bug378518.xul \
+		test_bug398135.xul \
+		test_bug398492.xul \
+		$(NULL)
+
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
+
+libs:: $(_CHROME_FILES)
+	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
+
--- a/content/xbl/test/test_bug296375.xul
+++ b/content/xbl/test/test_bug296375.xul
@@ -1,21 +1,21 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=296375
 -->
 <window title="Mozilla Bug 296375"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <title>Test for Bug 296375</title>
-  <script type="application/javascript" src="/MochiKit/packed.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>      
+  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
 
 <body  xmlns="http://www.w3.org/1999/xhtml">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=296375">Mozilla Bug 296375</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
--- a/content/xbl/test/test_bug378518.xul
+++ b/content/xbl/test/test_bug378518.xul
@@ -1,20 +1,20 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=378518
 -->
 <window title="Mozilla Bug 378518"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     
-  <script type="application/javascript" src="/MochiKit/packed.js" />
+  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
-    src="/tests/SimpleTest/SimpleTest.js"/>
+    src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
 
   <bindings xmlns="http://www.mozilla.org/xbl"
     xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
       <binding id="mybinding" extends="xul:checkbox">
           <content>
           </content>
       </binding>
--- a/content/xbl/test/test_bug398135.xul
+++ b/content/xbl/test/test_bug398135.xul
@@ -1,18 +1,18 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=398135
 -->
 <window title="Mozilla Bug 398135"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-  <script type="application/javascript" src="/MochiKit/packed.js"/>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript">window.log = ""</script>
   <bindings xmlns="http://www.mozilla.org/xbl">
     <binding id="ancestor">
       <implementation>
         <constructor>
           window.log += "ancestorConstructor:";
         </constructor>
         <destructor>
--- a/content/xbl/test/test_bug398492.xul
+++ b/content/xbl/test/test_bug398492.xul
@@ -1,18 +1,18 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=398492
 -->
 <window title="Mozilla Bug 398492"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-  <script type="application/javascript" src="/MochiKit/packed.js" />
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js" />
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <bindings xmlns="http://www.mozilla.org/xbl">
     <binding id="test">
       <content>
         <xul:hbox id="xxx"
             xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
           <children/>
         </xul:hbox>
       </content>
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -2295,16 +2295,21 @@ NPObjectMember_Call(JSContext *cx, uintN
 static void
 NPObjectMember_Trace(JSTracer *trc, JSObject *obj)
 {
   NPObjectMemberPrivate *memberPrivate =
     (NPObjectMemberPrivate *)::JS_GetPrivate(trc->context, obj);
   if (!memberPrivate)
     return;
 
+  // Our NPIdentifier is not always interned, so we must root it explicitly.
+  jsid id = NPIdentifierToJSId(memberPrivate->methodName);
+  if (JSID_IS_STRING(id))
+    JS_CALL_STRING_TRACER(trc, JSID_TO_STRING(id), "NPObjectMemberPrivate.methodName");
+
   if (!JSVAL_IS_PRIMITIVE(memberPrivate->fieldValue)) {
     JS_CALL_VALUE_TRACER(trc, memberPrivate->fieldValue,
                          "NPObject Member => fieldValue");
   }
 
   // There's no strong reference from our private data to the
   // NPObject, so make sure to mark the NPObject wrapper to keep the
   // NPObject alive as long as this NPObjectMember is alive.
--- a/editor/libeditor/base/tests/Makefile.in
+++ b/editor/libeditor/base/tests/Makefile.in
@@ -41,24 +41,24 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = editor/libeditor/base/tests
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = \
 		test_bug502673.html \
-		test_selection_move_commands.xul \
 		test_bug514156.html \
 		test_bug567213.html \
 		file_bug586662.html \
 		test_bug586662.html \
 		$(NULL)
 
 _CHROME_TEST_FILES = \
+		test_selection_move_commands.xul \
 		test_bug646194.xul \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
 libs:: $(_CHROME_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
--- a/editor/libeditor/base/tests/test_selection_move_commands.xul
+++ b/editor/libeditor/base/tests/test_selection_move_commands.xul
@@ -1,16 +1,16 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         title="Test for nsSelectionMoveCommands">
-  <script type="application/javascript" src="/MochiKit/packed.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 function runTest() {
   var tests = execTests();
   function execNext() {
     try {
--- a/gfx/angle/CONTRIBUTORS
+++ b/gfx/angle/CONTRIBUTORS
@@ -9,25 +9,26 @@
 TransGaming Inc.
  Nicolas Capens
  Daniel Koch
  Andrew Lewycky
  Gavriel State
  Shannon Woods
 
 Google Inc.
+ Brent Austin
  John Bauman
  Henry Bridge
- N. Duca
+ Nat Duca
  Vangelis Kokkevis
- Alok Priyadarshi
  Alastair Patrick
+ Alok Priyadarshi
  Kenneth Russell
+ Ben Vanik
  Adrienne Walker
- Ben Vanik
 
 Mozilla Corp.
  Vladimir Vukicevic
  Benoit Jacob
 
 Apple Inc.
  David Kilzer
 
--- a/gfx/angle/README.mozilla
+++ b/gfx/angle/README.mozilla
@@ -2,24 +2,26 @@ This is the ANGLE project, from http://c
 
 Current revision: r653
 
 == Applied local patches ==
 
 In this order:
   angle-nspr-misc.patch - don't bother with ANGLE_OS detection with NSPR
   angle-renaming.patch - rename debug.h to compilerdebug.h to avoid conflict in our makefiles
-  angle-makefiles.patch - Mozilla Makefiles for ANGLE
+  angle-intrinsic-msvc2005.patch - work around a MSVC 2005 compile error
+
+In addition to these patches, the Makefile.in files are ours, they're not present in upsteam ANGLE.
 
 == How to update this ANGLE copy ==
 
 1. Unapply patches
 2. Apply diff with new ANGLE version
-3. Reapply patches. Check for newly created/deleted files.
-4. For each file creation/deletetion recorded in step 3, update our makefiles (angle-makefiles.patch) accordingly
+3. Reapply patches.
+4. Check for changes in src/build_angle.gyp, update our Makefile.in files accordingly. Note that a single file may be recorded in more than one Makefile.
 
 == Visual Studio Solution Files ==
 
-Ignore these. We don't use them anymore. We use custom Makefiles (see angle-makefiles.patch)
+Ignore these. We don't use them anymore. We use custom Makefiles.
 
 == Generated parser code==
 
 Don't bother about that anymore. The parser is now generated and included in the ANGLE svn repo.
new file mode 100644
--- /dev/null
+++ b/gfx/angle/angle-instrinsic-msvc2005.patch
@@ -0,0 +1,54 @@
+# HG changeset patch
+# Parent 09fc6e32e6c5d4cdcb3c01f6849ccb8cdae7e8e0
+
+diff --git a/gfx/angle/src/libGLESv2/Texture.cpp b/gfx/angle/src/libGLESv2/Texture.cpp
+--- a/gfx/angle/src/libGLESv2/Texture.cpp
++++ b/gfx/angle/src/libGLESv2/Texture.cpp
+@@ -8,16 +8,22 @@
+ // Texture2D and TextureCubeMap. Implements GL texture objects and related
+ // functionality. [OpenGL ES 2.0.24] section 3.7 page 63.
+ 
+ #include "libGLESv2/Texture.h"
+ 
+ #include <d3dx9tex.h>
+ 
+ #include <algorithm>
++
++#if _MSC_VER <= 1400
++#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
++#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
++#endif
++
+ #include <intrin.h>
+ 
+ #include "common/debug.h"
+ 
+ #include "libEGL/Display.h"
+ 
+ #include "libGLESv2/main.h"
+ #include "libGLESv2/mathutil.h"
+diff --git a/gfx/angle/src/libGLESv2/mathutil.h b/gfx/angle/src/libGLESv2/mathutil.h
+--- a/gfx/angle/src/libGLESv2/mathutil.h
++++ b/gfx/angle/src/libGLESv2/mathutil.h
+@@ -3,16 +3,21 @@
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+ //
+ 
+ // mathutil.h: Math and bit manipulation functions.
+ 
+ #ifndef LIBGLESV2_MATHUTIL_H_
+ #define LIBGLESV2_MATHUTIL_H_
++
++#if _MSC_VER <= 1400
++#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
++#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
++#endif
+ 
+ #include <intrin.h>
+ #include <math.h>
+ #include <windows.h>
+ 
+ namespace gl
+ {
+ inline bool isPow2(int x)
deleted file mode 100644
--- a/gfx/angle/angle-makefiles.patch
+++ /dev/null
@@ -1,466 +0,0 @@
-# HG changeset patch
-# Parent 855fadd845692a09149ece53933c65113e05bb4f
-
-diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
---- a/gfx/angle/Makefile.in
-+++ b/gfx/angle/Makefile.in
-@@ -76,16 +76,18 @@ CPPSRCS = \
-         RemoveTree.cpp \
-         ShaderLang.cpp \
-         SymbolTable.cpp \
- 	VariableInfo.cpp \
- 	compilerdebug.cpp \
- 	ossource_nspr.cpp \
- 	util.cpp \
- 	ValidateLimitations.cpp \
-+	ForLoopUnroll.cpp \
-+	MapLongVariableNames.cpp \
- 	$(NULL)
- 
- # flex/yacc generated files
- CPPSRCS += \
- 	glslang_lex.cpp \
- 	glslang_tab.cpp \
- 	$(NULL)
- 
-@@ -101,16 +103,17 @@ CPPSRCS += \
- # can be selected.
- 
- ## HLSL translator backend
- ##CPPSRCS += \
- ##	CodeGenHLSL.cpp \
- ##	OutputHLSL.cpp \
- ##	TranslatorHLSL.cpp \
- ##	UnfoldSelect.cpp \
-+##	SearchSymbol.cpp \
- ##	$(NULL)
- 
- CSRCS   = \
-         atom.c \
-         cpp.c \
-         cppstruct.c \
-         memory.c \
-         scanner.c \
-@@ -119,77 +122,29 @@ CSRCS   = \
- 	$(NULL)
- 
- DEFINES += -DANGLE_USE_NSPR -DANGLE_BUILD
- 
- ifndef MOZ_ENABLE_LIBXUL
- EXTRA_DSO_LDOPTS = $(MOZ_COMPONENT_LIBS)
- endif
- 
-+# ANGLE only on Win32 for now, the solution isn't set up
-+# for 64-bit yet. This is handled by MOZ_ANGLE which the configure script
-+# leaves undefined in the 64-bit case.
-+ifdef MOZ_ANGLE
-+
-+# libEGL depends on (links against!) libGLESv2!
-+DIRS = src/libGLESv2 src/libEGL
-+
-+libs::
-+	expand "$(MOZ_D3DX9_CAB)" -F:$(MOZ_D3DX9_DLL) "$(DIST)/bin"
-+	expand "$(MOZ_D3DCOMPILER_CAB)" -F:$(MOZ_D3DCOMPILER_DLL) "$(DIST)/bin"
-+
-+endif
-+
- include $(topsrcdir)/config/rules.mk
- 
- # We have to filter out -pedantic, because of
- # comma-at-end-of-enumerator list failures.  We can try to get this fixed
- # upstream at some point.
- CXXFLAGS := $(filter-out -pedantic,$(CXXFLAGS))
- CFLAGS := $(filter-out -pedantic,$(CFLAGS))
--
--# ANGLE only on Win32 for now, the solution isn't set up
--# for 64-bit yet. This is handled by MOZ_ANGLE which the configure script
--# leaves undefined in the 64-bit case.
--ifdef MOZ_ANGLE
--ifdef MOZ_DEBUG
--ANGLE_DIR = Debug
--else
--ANGLE_DIR = Release
--endif
--
--ifdef MOZ_DIRECTX_SDK_PATH
--# export is needed for INCLUDE and LIB because devenv //useenv will read these env vars
--export INCLUDE := $(INCLUDE);$(MOZ_DIRECTX_SDK_PATH)\include
--export LIB := $(LIB);$(MOZ_DIRECTX_SDK_PATH)\lib\$(MOZ_DIRECTX_SDK_CPU_SUFFIX)
--endif
--
--ANGLE_DEP_PATTERNS = \
--	src/common/*.cpp src/common/*.h \
--	src/compiler/*.cpp src/compiler/*.h \
--	src/compiler/preprocessor/*.cpp src/compiler/preprocessor/*.h \
--	src/libEGL/*.cpp src/libEGL/*.h \
--	src/libGLESv2/*.cpp src/libGLESv2/*.h \
--	$(NULL)
--
--ANGLE_DEPS = $(filter-out Gen_glslang.cpp Gen_glslang_tab.cpp glslang_tab.h,$(wildcard $(ANGLE_DEP_PATTERNS)))
--
--libs:: libGLESv2.dll libEGL.dll
--	$(INSTALL) $(IFLAGS2) libGLESv2.dll libEGL.dll $(MOZ_D3DX9_DLL) $(MOZ_D3DCOMPILER_DLL) $(DIST)/bin
--
--# we don't want this to attempt to parallel-build these dlls;
--# building one will build both.
--libGLESv2.dll: libEGL.dll
--
--libEGL.dll: $(GLOBAL_DEPS) $(ANGLE_DEPS)
--	@(echo "=== Building ANGLE via devenv.exe ===" \
--	&& rm -rf angle-build && mkdir angle-build \
--	&& cp -r $(srcdir)/src $(srcdir)/include angle-build \
--	&& cd angle-build/src \
--	&& echo "Upgrading solution..." \
--	&& devenv angle.sln //upgrade \
--	&& echo "Tweaking project files to use ASLR and DEP..." \
--	&& ( find . -name '*proj' | xargs \
--	     perl -i.bak -p \
--	          -e 'BEGIN{undef $/;} s/<RandomizedBaseAddress>([^<^>])*<\/RandomizedBaseAddress>/<RandomizedBaseAddress>true<\/RandomizedBaseAddress>/sgmi;' \
--	          -e 'BEGIN{undef $/;} s/<DataExecutionPrevention>([^<^>])*<\/DataExecutionPrevention>/<DataExecutionPrevention>true<\/DataExecutionPrevention>/sgmi;' \
--		  -e 's/RandomizedBaseAddress\=\"0\"/RandomizedBaseAddress\=\"1\"/g;' \
--		  -e 's/DataExecutionPrevention\=\"0\"/DataExecutionPrevention\=\"1\"/g;' \
--	   ) \
--	&& echo "Building solution, target $(ANGLE_DIR)|Win32..." \
--	&& ( devenv angle.sln //useenv //build "$(ANGLE_DIR)|Win32" //out ../../angle-build-log.txt \
--	       || (cat ../../angle-build-log.txt && exit 1) \
--	   ) \
--	&& echo "Copying dlls..." \
--	&& cp $(ANGLE_DIR)/*.dll ../.. \
--	&& cd ../.. \
--	&& echo "Extracting dlls from cab file..." \
--	&& expand "$(MOZ_D3DX9_CAB)" . -F:$(MOZ_D3DX9_DLL) \
--	&& expand "$(MOZ_D3DCOMPILER_CAB)" . -F:$(MOZ_D3DCOMPILER_DLL) \
--	)
--
--endif
-diff --git a/gfx/angle/src/libEGL/Makefile.in b/gfx/angle/src/libEGL/Makefile.in
-new file mode 100644
---- /dev/null
-+++ b/gfx/angle/src/libEGL/Makefile.in
-@@ -0,0 +1,142 @@
-+# 
-+# ***** BEGIN LICENSE BLOCK *****
-+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-+#
-+# The contents of this file are subject to the Mozilla Public License Version
-+# 1.1 (the "License"); you may not use this file except in compliance with
-+# the License. You may obtain a copy of the License at
-+# http://www.mozilla.org/MPL/
-+#
-+# Software distributed under the License is distributed on an "AS IS" basis,
-+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-+# for the specific language governing rights and limitations under the
-+# License.
-+#
-+# The Original Code is gecko.
-+#
-+# The Initial Developer of the Original Code is Mozilla Foundation.
-+# Portions created by the Initial Developer are Copyright (C) 2011
-+# the Initial Developer. All Rights Reserved.
-+#
-+# Contributor(s):
-+#
-+# Alternatively, the contents of this file may be used under the terms of
-+# either of the GNU General Public License Version 2 or later (the "GPL"),
-+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-+# in which case the provisions of the GPL or the LGPL are applicable instead
-+# of those above. If you wish to allow use of your version of this file only
-+# under the terms of either the GPL or the LGPL, and not to allow others to
-+# use your version of this file under the terms of the MPL, indicate your
-+# decision by deleting the provisions above and replace them with the notice
-+# and other provisions required by the GPL or the LGPL. If you do not delete
-+# the provisions above, a recipient may use your version of this file under
-+# the terms of any one of the MPL, the GPL or the LGPL.
-+#
-+# ***** END LICENSE BLOCK *****
-+
-+DEPTH    = ../../../..
-+topsrcdir  = @top_srcdir@
-+srcdir    = @srcdir@
-+VPATH    = @srcdir@
-+
-+include $(DEPTH)/config/autoconf.mk
-+
-+MODULE = libegl
-+# On Windows, we don't automatically get "lib" prepended, but we need it.
-+LIBRARY_NAME = libEGL
-+MODULE_NAME = libegl
-+FORCE_SHARED_LIB=1
-+
-+# ANGLE uses the STL, so we can't use our derpy STL wrappers.
-+STL_FLAGS=
-+
-+# ANGLE uses exceptions internally, so we need to have exception handling
-+# support
-+ENABLE_CXX_EXCEPTIONS=1
-+
-+# Since we're building off in our own world, we don't want to have
-+# mozilla-config.h and -DMOZILLA_CLIENT automatically included and defined, so
-+# we just overwrite OS_COMPILE_C(XX)FLAGS.
-+OS_COMPILE_CFLAGS = $(OS_CPPFLAGS)
-+OS_COMPILE_CXXFLAGS = $(OS_CPPFLAGS)
-+
-+LOCAL_INCLUDES += -I$(srcdir)/../../include -I$(srcdir)/.. -I"$(DXSDK_DIR)/include"
-+
-+VPATH += $(srcdir)/.. \
-+  $(srcdir)/../compiler \
-+  $(srcdir)/../compiler/preprocessor \
-+  $(srcdir)/../common \
-+  $(NULL)
-+
-+# Translator/compiler first
-+
-+CPPSRCS = \
-+  Compiler.cpp \
-+  InfoSink.cpp \
-+  Initialize.cpp \
-+  InitializeDll.cpp \
-+  Intermediate.cpp \
-+  intermOut.cpp \
-+  IntermTraverse.cpp \
-+  MozAngleLink.cpp \
-+  parseConst.cpp \
-+  ParseHelper.cpp \
-+  PoolAlloc.cpp \
-+  QualifierAlive.cpp \
-+  RemoveTree.cpp \
-+  ShaderLang.cpp \
-+  SymbolTable.cpp \
-+  VariableInfo.cpp \
-+  compilerdebug.cpp \
-+  ossource_win.cpp \
-+  util.cpp \
-+  ValidateLimitations.cpp \
-+  ForLoopUnroll.cpp \
-+  MapLongVariableNames.cpp \
-+  $(NULL)
-+
-+# flex/yacc generated files
-+CPPSRCS += \
-+  glslang_lex.cpp \
-+  glslang_tab.cpp \
-+  $(NULL)
-+
-+# HLSL translator backend
-+CPPSRCS += \
-+  CodeGenHLSL.cpp \
-+  OutputHLSL.cpp \
-+  TranslatorHLSL.cpp \
-+  UnfoldSelect.cpp \
-+  SearchSymbol.cpp \
-+  $(NULL)
-+
-+CSRCS   = \
-+  atom.c \
-+  cpp.c \
-+  cppstruct.c \
-+  memory.c \
-+  scanner.c \
-+  symbols.c \
-+  tokens.c \
-+  $(NULL)
-+
-+DEFINES += -DANGLE_BUILD -DNOMINMAX -DLIBEGL_EXPORTS -D_CRT_SECURE_NO_DEPRECATE
-+
-+ifndef MOZ_DEBUG
-+DEFINES += -D_SECURE_SCL=0
-+endif
-+
-+CPPSRCS += \
-+  debug.cpp \
-+  Config.cpp \
-+  Display.cpp \
-+  libEGL.cpp \
-+  main.cpp \
-+  Surface.cpp \
-+  $(NULL)
-+
-+DEFFILE = $(srcdir)/libEGL.def
-+
-+include $(topsrcdir)/config/rules.mk
-+
-+EXTRA_DSO_LDOPTS = "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/d3d9.lib" "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/dxguid.lib" $(DIST)/lib/libGLESv2.lib
-diff --git a/gfx/angle/src/libGLESv2/Makefile.in b/gfx/angle/src/libGLESv2/Makefile.in
-new file mode 100644
---- /dev/null
-+++ b/gfx/angle/src/libGLESv2/Makefile.in
-@@ -0,0 +1,157 @@
-+# 
-+# ***** BEGIN LICENSE BLOCK *****
-+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-+#
-+# The contents of this file are subject to the Mozilla Public License Version
-+# 1.1 (the "License"); you may not use this file except in compliance with
-+# the License. You may obtain a copy of the License at
-+# http://www.mozilla.org/MPL/
-+#
-+# Software distributed under the License is distributed on an "AS IS" basis,
-+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-+# for the specific language governing rights and limitations under the
-+# License.
-+#
-+# The Original Code is gecko.
-+#
-+# The Initial Developer of the Original Code is Mozilla Foundation.
-+# Portions created by the Initial Developer are Copyright (C) 2011
-+# the Initial Developer. All Rights Reserved.
-+#
-+# Contributor(s):
-+#
-+# Alternatively, the contents of this file may be used under the terms of
-+# either of the GNU General Public License Version 2 or later (the "GPL"),
-+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-+# in which case the provisions of the GPL or the LGPL are applicable instead
-+# of those above. If you wish to allow use of your version of this file only
-+# under the terms of either the GPL or the LGPL, and not to allow others to
-+# use your version of this file under the terms of the MPL, indicate your
-+# decision by deleting the provisions above and replace them with the notice
-+# and other provisions required by the GPL or the LGPL. If you do not delete
-+# the provisions above, a recipient may use your version of this file under
-+# the terms of any one of the MPL, the GPL or the LGPL.
-+#
-+# ***** END LICENSE BLOCK *****
-+
-+DEPTH		= ../../../..
-+topsrcdir	= @top_srcdir@
-+srcdir		= @srcdir@
-+VPATH		= @srcdir@
-+
-+include $(DEPTH)/config/autoconf.mk
-+
-+MODULE = libglesv2
-+# On Windows, we don't automatically get "lib" prepended, but we need it.
-+LIBRARY_NAME = libGLESv2
-+MODULE_NAME = libglesv2
-+FORCE_SHARED_LIB=1
-+
-+# ANGLE uses the STL, so we can't use our derpy STL wrappers.
-+STL_FLAGS=
-+
-+# ANGLE uses exceptions internally, so we need to have exception handling
-+# support
-+ENABLE_CXX_EXCEPTIONS=1
-+
-+# Since we're building off in our own world, we don't want to have
-+# mozilla-config.h and -DMOZILLA_CLIENT automatically included and defined, so
-+# we just overwrite OS_COMPILE_C(XX)FLAGS.
-+OS_COMPILE_CFLAGS = $(OS_CPPFLAGS)
-+OS_COMPILE_CXXFLAGS = $(OS_CPPFLAGS)
-+
-+LOCAL_INCLUDES = -I$(srcdir)/../../include -I$(srcdir)/.. -I"$(DXSDK_DIR)/include"
-+
-+VPATH += $(srcdir)/..
-+VPATH += $(srcdir)/../compiler
-+VPATH += $(srcdir)/../compiler/preprocessor
-+VPATH += $(srcdir)/../common
-+VPATH += $(srcdir)/geometry
-+
-+# Translator/compiler first
-+
-+CPPSRCS = \
-+	Compiler.cpp \
-+        InfoSink.cpp \
-+        Initialize.cpp \
-+        InitializeDll.cpp \
-+        Intermediate.cpp \
-+        intermOut.cpp \
-+        IntermTraverse.cpp \
-+        MozAngleLink.cpp \
-+        parseConst.cpp \
-+        ParseHelper.cpp \
-+        PoolAlloc.cpp \
-+        QualifierAlive.cpp \
-+        RemoveTree.cpp \
-+        ShaderLang.cpp \
-+        SymbolTable.cpp \
-+        VariableInfo.cpp \
-+        compilerdebug.cpp \
-+        ossource_win.cpp \
-+        util.cpp \
-+        ValidateLimitations.cpp \
-+	ForLoopUnroll.cpp \
-+	MapLongVariableNames.cpp \
-+	$(NULL)
-+
-+# flex/yacc generated files
-+CPPSRCS += \
-+	glslang_lex.cpp \
-+	glslang_tab.cpp \
-+	$(NULL)
-+
-+# HLSL translator backend
-+CPPSRCS += \
-+	CodeGenHLSL.cpp \
-+	OutputHLSL.cpp \
-+	TranslatorHLSL.cpp \
-+	UnfoldSelect.cpp \
-+	SearchSymbol.cpp \
-+	$(NULL)
-+
-+CSRCS   = \
-+        atom.c \
-+        cpp.c \
-+        cppstruct.c \
-+        memory.c \
-+        scanner.c \
-+        symbols.c \
-+        tokens.c \
-+	$(NULL)
-+
-+DEFINES += -DANGLE_BUILD -DNOMINMAX -DLIBGLESV2_EXPORTS -D_CRT_SECURE_NO_DEPRECATE
-+
-+ifndef MOZ_DEBUG
-+DEFINES += -D_SECURE_SCL=0
-+endif
-+
-+CPPSRCS	+= \
-+	debug.cpp \
-+	IndexDataManager.cpp \
-+	VertexDataManager.cpp \
-+	Blit.cpp \
-+	Buffer.cpp \
-+	Context.cpp \
-+	Fence.cpp \
-+	Framebuffer.cpp \
-+	libGLESv2.cpp \
-+	main.cpp \
-+	Program.cpp \
-+	RefCountObject.cpp \
-+	Renderbuffer.cpp \
-+	ResourceManager.cpp \
-+	Shader.cpp \
-+	Texture.cpp \
-+	utilities.cpp \
-+	HandleAllocator.cpp \
-+	IndexDataManager.cpp \
-+	VertexDataManager.cpp \
-+	$(NULL)
-+
-+DEFFILE = $(srcdir)/libGLESv2.def
-+
-+
-+include $(topsrcdir)/config/rules.mk
-+
-+EXTRA_DSO_LDOPTS = "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/d3d9.lib" "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/d3dx9.lib"
-diff --git a/toolkit/toolkit-makefiles.sh b/toolkit/toolkit-makefiles.sh
---- a/toolkit/toolkit-makefiles.sh
-+++ b/toolkit/toolkit-makefiles.sh
-@@ -123,16 +123,18 @@ MAKEFILES_gfx="
-   gfx/Makefile
-   gfx/ycbcr/Makefile
-   gfx/layers/Makefile
-   gfx/src/Makefile
-   gfx/tests/Makefile
-   gfx/thebes/Makefile
-   gfx/qcms/Makefile
-   gfx/angle/Makefile
-+  gfx/angle/src/libGLESv2/Makefile
-+  gfx/angle/src/libEGL/Makefile
- "
- 
- MAKEFILES_htmlparser="
-   parser/htmlparser/Makefile
-   parser/htmlparser/public/Makefile
-   parser/htmlparser/src/Makefile
-   parser/htmlparser/tests/Makefile
-   parser/htmlparser/tests/grabpage/Makefile
--- a/gfx/angle/angle-nspr-misc.patch
+++ b/gfx/angle/angle-nspr-misc.patch
@@ -1,10 +1,10 @@
 # HG changeset patch
-# Parent 3e177ced3662763eae55f4b741258298609e99aa
+# Parent 99de3c7d00973e65e295911b2b8b66c75cfe24bb
 diff --git a/gfx/angle/src/compiler/osinclude.h b/gfx/angle/src/compiler/osinclude.h
 --- a/gfx/angle/src/compiler/osinclude.h
 +++ b/gfx/angle/src/compiler/osinclude.h
 @@ -7,17 +7,19 @@
  #ifndef __OSINCLUDE_H
  #define __OSINCLUDE_H
  
  //
--- a/gfx/angle/angle-renaming-debug.patch
+++ b/gfx/angle/angle-renaming-debug.patch
@@ -1,10 +1,10 @@
 # HG changeset patch
-# Parent 593e84b864c5470aa43682d308212878b0b4e5d9
+# Parent a0dd1332c0e6ebaf429f9a3732b8901f9e46cde0
 diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
 --- a/gfx/angle/Makefile.in
 +++ b/gfx/angle/Makefile.in
 @@ -72,17 +72,17 @@ CPPSRCS = \
          parseConst.cpp \
          ParseHelper.cpp \
          PoolAlloc.cpp \
          QualifierAlive.cpp \
@@ -12,21 +12,21 @@ diff --git a/gfx/angle/Makefile.in b/gfx
          ShaderLang.cpp \
          SymbolTable.cpp \
  	VariableInfo.cpp \
 -	debug.cpp \
 +	compilerdebug.cpp \
  	ossource_nspr.cpp \
  	util.cpp \
  	ValidateLimitations.cpp \
+ 	ForLoopUnroll.cpp \
+ 	MapLongVariableNames.cpp \
  	$(NULL)
  
  # flex/yacc generated files
- CPPSRCS += \
- 	glslang_lex.cpp \
 diff --git a/gfx/angle/src/build_angle.gyp b/gfx/angle/src/build_angle.gyp
 --- a/gfx/angle/src/build_angle.gyp
 +++ b/gfx/angle/src/build_angle.gyp
 @@ -17,18 +17,18 @@
          '.',
          '../include',
        ],
        'sources': [
@@ -152,17 +152,17 @@ diff --git a/gfx/angle/src/compiler/comp
  
  #include <assert.h>
  
  #ifdef _DEBUG
  #define TRACE_ENABLED  // define to enable debug message tracing
 diff --git a/gfx/angle/src/compiler/osinclude.h b/gfx/angle/src/compiler/osinclude.h
 --- a/gfx/angle/src/compiler/osinclude.h
 +++ b/gfx/angle/src/compiler/osinclude.h
-@@ -32,17 +32,17 @@
+@@ -30,17 +30,17 @@
  #include <windows.h>
  #elif defined(ANGLE_OS_POSIX)
  #include <pthread.h>
  #include <semaphore.h>
  #include <errno.h>
  #endif  // ANGLE_USE_NSPR
  
  
--- a/gfx/angle/build/common.gypi
+++ b/gfx/angle/build/common.gypi
@@ -82,17 +82,42 @@
       },  # Release
     },  # configurations
   },  # target_defaults
   'conditions': [
     ['OS=="win"', {
       'target_defaults': {
         'msvs_cygwin_dirs': ['../third_party/cygwin'],
       },
-    }]
+    }],
+    ['OS!="win" and OS!="mac"', {
+      'target_defaults': {
+        'cflags': [
+          '-pthread',
+          '-fno-exceptions',
+        ],
+        'ldflags': [
+          '-pthread',
+        ],
+        'configurations': {
+          'Debug': {
+            'variables': {
+              'debug_optimize%': '0',
+            },
+            'defines': [
+              '_DEBUG',
+            ],
+            'cflags': [
+              '-O>(debug_optimize)',
+              '-g',
+            ],
+          }
+        },
+      },
+    }],
   ],
 }
 
 # Local Variables:
 # tab-width:2
 # indent-tabs-mode:nil
 # End:
 # vim: set expandtab tabstop=2 shiftwidth=2:
--- a/gfx/angle/build/gyp_angle
+++ b/gfx/angle/build/gyp_angle
@@ -17,13 +17,17 @@ sys.path.append(os.path.join(angle_dir, 
 import gyp
 
 if __name__ == '__main__':
   args = sys.argv[1:]
 
   print 'Updating projects from gyp files...'
   sys.stdout.flush()
 
+  # Set the depth to get the top-level Makefile generated into the
+  # correct directory. This only has an effect on Linux.
+  args.append('--depth');
+  args.append('./trunk');
   # Add common.gypi to the include path.
   args.append('-I' + os.path.join(script_dir, 'common.gypi'))
   # Add all.gyp as the main gyp file to be generated.
   args.append(os.path.join(script_dir, 'all.gyp'))
   sys.exit(gyp.main(args))
--- a/gfx/angle/samples/translator/translator.cpp
+++ b/gfx/angle/samples/translator/translator.cpp
@@ -22,17 +22,17 @@ enum TFailCode {
     EFailCompile,
     EFailCompilerCreate,
 };
 
 static void usage();
 static ShShaderType FindShaderType(const char* fileName);
 static bool CompileFile(char* fileName, ShHandle compiler, int compileOptions);
 static void LogMsg(char* msg, const char* name, const int num, const char* logName);
-static void PrintActiveVariables(ShHandle compiler, ShShaderInfo varType);
+static void PrintActiveVariables(ShHandle compiler, ShShaderInfo varType, bool mapLongVariableNames);
 
 // If NUM_SOURCE_STRINGS is set to a value > 1, the input file data is
 // broken into that many chunks.
 const unsigned int NUM_SOURCE_STRINGS = 2;
 typedef std::vector<char*> ShaderSource;
 static bool ReadShaderSource(const char* fileName, ShaderSource& source);
 static void FreeShaderSource(ShaderSource& source);
 
@@ -70,19 +70,20 @@ int main(int argc, char* argv[])
     ShInitialize();
 
     ShBuiltInResources resources;
     GenerateResources(&resources);
 
     argc--;
     argv++;
     for (; (argc >= 1) && (failCode == ESuccess); argc--, argv++) {
-        if (argv[0][0] == '-' || argv[0][0] == '/') {
+        if (argv[0][0] == '-') {
             switch (argv[0][1]) {
             case 'i': compileOptions |= SH_INTERMEDIATE_TREE; break;
+            case 'm': compileOptions |= SH_MAP_LONG_VARIABLE_NAMES; break;
             case 'o': compileOptions |= SH_OBJECT_CODE; break;
             case 'u': compileOptions |= SH_ATTRIBUTES_UNIFORMS; break;
             default: failCode = EFailUsage;
             }
         } else {
             ShHandle compiler = 0;
             switch (FindShaderType(argv[0])) {
             case SH_VERTEX_SHADER:
@@ -114,22 +115,22 @@ int main(int argc, char* argv[])
                   buffer = (char*) realloc(buffer, bufferLen * sizeof(char));
                   ShGetObjectCode(compiler, buffer);
                   puts(buffer);
                   LogMsg("END", "COMPILER", numCompiles, "OBJ CODE");
                   printf("\n\n");
               }
               if (compiled && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) {
                   LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE ATTRIBS");
-                  PrintActiveVariables(compiler, SH_ACTIVE_ATTRIBUTES);
+                  PrintActiveVariables(compiler, SH_ACTIVE_ATTRIBUTES, compileOptions & SH_MAP_LONG_VARIABLE_NAMES);
                   LogMsg("END", "COMPILER", numCompiles, "ACTIVE ATTRIBS");
                   printf("\n\n");
 
                   LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE UNIFORMS");
-                  PrintActiveVariables(compiler, SH_ACTIVE_UNIFORMS);
+                  PrintActiveVariables(compiler, SH_ACTIVE_UNIFORMS, compileOptions & SH_MAP_LONG_VARIABLE_NAMES);
                   LogMsg("END", "COMPILER", numCompiles, "ACTIVE UNIFORMS");
                   printf("\n\n");
               }
               if (!compiled)
                   failCode = EFailCompile;
               ++numCompiles;
             } else {
                 failCode = EFailCompilerCreate;
@@ -153,19 +154,20 @@ int main(int argc, char* argv[])
     return failCode;
 }
 
 //
 //   print usage to stdout
 //
 void usage()
 {
-    printf("Usage: translate [-i -o -u] file1 file2 ...\n"
+    printf("Usage: translate [-i -m -o -u] file1 file2 ...\n"
         "Where: filename = filename ending in .frag or .vert\n"
         "       -i = print intermediate tree\n"
+        "       -m = map long variable names\n"
         "       -o = print translated code\n"
         "       -u = print active attribs and uniforms\n");
 }
 
 //
 //   Deduce the shader type from the filename.  Files must end in one of the
 //   following extensions:
 //
@@ -204,42 +206,49 @@ bool CompileFile(char* fileName, ShHandl
     return ret ? true : false;
 }
 
 void LogMsg(char* msg, const char* name, const int num, const char* logName)
 {
     printf("#### %s %s %d %s ####\n", msg, name, num, logName);
 }
 
-void PrintActiveVariables(ShHandle compiler, ShShaderInfo varType)
+void PrintActiveVariables(ShHandle compiler, ShShaderInfo varType, bool mapLongVariableNames)
 {
     int nameSize = 0;
     switch (varType) {
         case SH_ACTIVE_ATTRIBUTES:
             ShGetInfo(compiler, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, &nameSize);
             break;
         case SH_ACTIVE_UNIFORMS:
             ShGetInfo(compiler, SH_ACTIVE_UNIFORM_MAX_LENGTH, &nameSize);
             break;
         default: assert(0);
     }
     if (nameSize <= 1) return;
     char* name = new char[nameSize];
 
+    char* mappedName = NULL;
+    if (mapLongVariableNames) {
+        int mappedNameSize = 0;
+        ShGetInfo(compiler, SH_MAPPED_NAME_MAX_LENGTH, &mappedNameSize);
+        mappedName = new char[mappedNameSize];
+    }
+
     int activeVars = 0, size = 0;
     ShDataType type = SH_NONE;
     char* typeName = NULL;
     ShGetInfo(compiler, varType, &activeVars);
     for (int i = 0; i < activeVars; ++i) {
         switch (varType) {
             case SH_ACTIVE_ATTRIBUTES:
-                ShGetActiveAttrib(compiler, i, NULL, &size, &type, name, NULL);
+                ShGetActiveAttrib(compiler, i, NULL, &size, &type, name, mappedName);
                 break;
             case SH_ACTIVE_UNIFORMS:
-                ShGetActiveUniform(compiler, i, NULL, &size, &type, name, NULL);
+                ShGetActiveUniform(compiler, i, NULL, &size, &type, name, mappedName);
                 break;
             default: assert(0);
         }
         switch (type) {
             case SH_FLOAT: typeName = "GL_FLOAT"; break;
             case SH_FLOAT_VEC2: typeName = "GL_FLOAT_VEC2"; break;
             case SH_FLOAT_VEC3: typeName = "GL_FLOAT_VEC3"; break;
             case SH_FLOAT_VEC4: typeName = "GL_FLOAT_VEC4"; break;
@@ -253,19 +262,24 @@ void PrintActiveVariables(ShHandle compi
             case SH_BOOL_VEC4: typeName = "GL_BOOL_VEC4"; break;
             case SH_FLOAT_MAT2: typeName = "GL_FLOAT_MAT2"; break;
             case SH_FLOAT_MAT3: typeName = "GL_FLOAT_MAT3"; break;
             case SH_FLOAT_MAT4: typeName = "GL_FLOAT_MAT4"; break;
             case SH_SAMPLER_2D: typeName = "GL_SAMPLER_2D"; break;
             case SH_SAMPLER_CUBE: typeName = "GL_SAMPLER_CUBE"; break;
             default: assert(0);
         }
-        printf("%d: name:%s type:%s size:%d\n", i, name, typeName, size);
+        printf("%d: name:%s type:%s size:%d", i, name, typeName, size);
+        if (mapLongVariableNames)
+            printf(" mapped name:%s", mappedName);
+        printf("\n");
     }
     delete [] name;
+    if (mappedName)
+        delete [] mappedName;
 }
 
 static bool ReadShaderSource(const char* fileName, ShaderSource& source) {
     FILE* in = fopen(fileName, "rb");
     if (!in) {
         printf("Error: unable to open input file: %s\n", fileName);
         return false;
     }
--- a/gfx/angle/src/build_angle.gyp
+++ b/gfx/angle/src/build_angle.gyp
@@ -223,17 +223,21 @@
             'libEGL/Surface.h',
           ],
           'msvs_settings': {
             'VCLinkerTool': {
               'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'],
               'AdditionalDependencies': [
                 'd3d9.lib',
                 'dxguid.lib',
+                'dwmapi.lib',
               ],
+              'DelayLoadDLLs': [
+                'dwmapi.dll',
+              ]
             }
           },
         },
       ],
     }],
   ],
 }
 
--- a/gfx/angle/src/common/version.h
+++ b/gfx/angle/src/common/version.h
@@ -1,10 +1,10 @@
 #define MAJOR_VERSION 0
 #define MINOR_VERSION 0
 #define BUILD_VERSION 0
-#define BUILD_REVISION 653
+#define BUILD_REVISION 686
 
 #define STRINGIFY(x) #x
 #define MACRO_STRINGIFY(x) STRINGIFY(x)
 
 #define REVISION_STRING MACRO_STRINGIFY(BUILD_REVISION)
 #define VERSION_STRING MACRO_STRINGIFY(MAJOR_VERSION) "." MACRO_STRINGIFY(MINOR_VERSION) "." MACRO_STRINGIFY(BUILD_VERSION) "." MACRO_STRINGIFY(BUILD_REVISION)
--- a/gfx/angle/src/compiler/Compiler.cpp
+++ b/gfx/angle/src/compiler/Compiler.cpp
@@ -202,16 +202,16 @@ bool TCompiler::validateLimitations(TInt
 void TCompiler::collectAttribsUniforms(TIntermNode* root)
 {
     CollectAttribsUniforms collect(attribs, uniforms);
     root->traverse(&collect);
 }
 
 void TCompiler::mapLongVariableNames(TIntermNode* root)
 {
-    MapLongVariableNames map;
+    MapLongVariableNames map(varyingLongNameMap);
     root->traverse(&map);
 }
 
 int TCompiler::getMappedNameMaxLength() const
 {
     return MAX_IDENTIFIER_NAME_SIZE + 1;
 }
--- a/gfx/angle/src/compiler/MapLongVariableNames.cpp
+++ b/gfx/angle/src/compiler/MapLongVariableNames.cpp
@@ -3,32 +3,54 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
 
 #include "compiler/MapLongVariableNames.h"
 
 namespace {
 
-TString mapLongName(int id, const TString& name)
+TString mapLongName(int id, const TString& name, bool isVarying)
 {
     ASSERT(name.size() > MAX_IDENTIFIER_NAME_SIZE);
     TStringStream stream;
-    stream << "webgl_" << id << "_";
+    stream << "webgl_";
+    if (isVarying)
+        stream << "v";
+    stream << id << "_";
     stream << name.substr(0, MAX_IDENTIFIER_NAME_SIZE - stream.str().size());
     return stream.str();
 }
 
 }  // anonymous namespace
 
+MapLongVariableNames::MapLongVariableNames(
+    TMap<TString, TString>& varyingLongNameMap)
+    : mVaryingLongNameMap(varyingLongNameMap)
+{
+}
+
 void MapLongVariableNames::visitSymbol(TIntermSymbol* symbol)
 {
     ASSERT(symbol != NULL);
-    if (symbol->getSymbol().size() > MAX_IDENTIFIER_NAME_SIZE)
-        symbol->setSymbol(mapLongName(symbol->getId(), symbol->getSymbol()));
+    if (symbol->getSymbol().size() > MAX_IDENTIFIER_NAME_SIZE) {
+        switch (symbol->getQualifier()) {
+          case EvqVaryingIn:
+          case EvqVaryingOut:
+          case EvqInvariantVaryingIn:
+          case EvqInvariantVaryingOut:
+            symbol->setSymbol(
+                mapVaryingLongName(symbol->getSymbol()));
+            break;
+          default:
+            symbol->setSymbol(
+                mapLongName(symbol->getId(), symbol->getSymbol(), false));
+            break;
+        };
+    }
 }
 
 void MapLongVariableNames::visitConstantUnion(TIntermConstantUnion*)
 {
 }
 
 bool MapLongVariableNames::visitBinary(Visit, TIntermBinary*)
 {
@@ -54,8 +76,21 @@ bool MapLongVariableNames::visitLoop(Vis
 {
     return true;
 }
 
 bool MapLongVariableNames::visitBranch(Visit, TIntermBranch*)
 {
     return true;
 }
+
+TString MapLongVariableNames::mapVaryingLongName(const TString& name)
+{
+    TMap<TString, TString>::const_iterator it = mVaryingLongNameMap.find(name);
+    if (it != mVaryingLongNameMap.end())
+        return (*it).second;
+
+    int id = mVaryingLongNameMap.size();
+    TString mappedName = mapLongName(id, name, true);
+    mVaryingLongNameMap.insert(
+        TMap<TString, TString>::value_type(name, mappedName));
+    return mappedName;
+}
--- a/gfx/angle/src/compiler/MapLongVariableNames.h
+++ b/gfx/angle/src/compiler/MapLongVariableNames.h
@@ -14,21 +14,26 @@
 
 // This size does not include '\0' in the end.
 #define MAX_IDENTIFIER_NAME_SIZE 32
 
 // Traverses intermediate tree to map attributes and uniforms names that are
 // longer than MAX_IDENTIFIER_NAME_SIZE to MAX_IDENTIFIER_NAME_SIZE.
 class MapLongVariableNames : public TIntermTraverser {
 public:
-    MapLongVariableNames() { }
+    MapLongVariableNames(TMap<TString, TString>& varyingLongNameMap);
 
     virtual void visitSymbol(TIntermSymbol*);
     virtual void visitConstantUnion(TIntermConstantUnion*);
     virtual bool visitBinary(Visit, TIntermBinary*);
     virtual bool visitUnary(Visit, TIntermUnary*);
     virtual bool visitSelection(Visit, TIntermSelection*);
     virtual bool visitAggregate(Visit, TIntermAggregate*);
     virtual bool visitLoop(Visit, TIntermLoop*);
     virtual bool visitBranch(Visit, TIntermBranch*);
+
+private:
+    TString mapVaryingLongName(const TString& name);
+
+    TMap<TString, TString>& mVaryingLongNameMap;
 };
 
 #endif  // COMPILER_MAP_LONG_VARIABLE_NAMES_H_
--- a/gfx/angle/src/compiler/OutputHLSL.cpp
+++ b/gfx/angle/src/compiler/OutputHLSL.cpp
@@ -1875,16 +1875,17 @@ void OutputHLSL::outputTriplet(Visit vis
         out << postString;
     }
 }
 
 void OutputHLSL::outputLineDirective(int line)
 {
     if ((mContext.compileOptions & SH_LINE_DIRECTIVES) && (line > 0))
     {
+        mBody << "\n";
         mBody << "#line " << line;
 
         if (mContext.sourcePath)
         {
             mBody << " \"" << mContext.sourcePath << "\"";
         }
         
         mBody << "\n";
--- a/gfx/angle/src/compiler/ShHandle.h
+++ b/gfx/angle/src/compiler/ShHandle.h
@@ -85,16 +85,19 @@ private:
     TSymbolTable symbolTable;
     // Built-in extensions with default behavior.
     TExtensionBehavior extensionBehavior;
 
     // Results of compilation.
     TInfoSink infoSink;  // Output sink.
     TVariableInfoList attribs;  // Active attributes in the compiled shader.
     TVariableInfoList uniforms;  // Active uniforms in the compiled shader.
+
+    // Pair of long varying varibale name <originalName, mappedName>.
+    TMap<TString, TString> varyingLongNameMap;
 };
 
 //
 // This is the interface between the machine independent code
 // and the machine dependent code.
 //
 // The machine dependent code should derive from the classes
 // above. Then Construct*() and Delete*() will create and 
--- a/gfx/angle/src/compiler/glslang.y
+++ b/gfx/angle/src/compiler/glslang.y
@@ -1283,37 +1283,22 @@ single_declaration
 
         TVariable* variable = 0;
         if (context->nonInitErrorCheck($2.line, *$2.string, $$.type, variable))
             context->recover();
         if (variable && symbol)
             symbol->setId(variable->getUniqueId());
     }
     | fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET {
+        context->error($2.line, "unsized array declarations not supported", $2.string->c_str(), "");
+        context->recover();
+
         TIntermSymbol* symbol = context->intermediate.addSymbol(0, *$2.string, TType($1), $2.line);
         $$.intermAggregate = context->intermediate.makeAggregate(symbol, $2.line);
-        
-        if (context->structQualifierErrorCheck($2.line, $1))
-            context->recover();
-
-        if (context->nonInitConstErrorCheck($2.line, *$2.string, $1))
-            context->recover();
-
         $$.type = $1;
-
-        if (context->arrayTypeErrorCheck($3.line, $1) || context->arrayQualifierErrorCheck($3.line, $1))
-            context->recover();
-        else {
-            $1.setArray(true);
-            TVariable* variable = 0;
-            if (context->arrayErrorCheck($3.line, *$2.string, $1, variable))
-                context->recover();
-            if (variable && symbol)
-                symbol->setId(variable->getUniqueId());
-        }
     }
     | fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
         TType type = TType($1);
         int size;
         if (context->arraySizeErrorCheck($2.line, $4, size))
             context->recover();
         type.setArraySize(size);
         TIntermSymbol* symbol = context->intermediate.addSymbol(0, *$2.string, type, $2.line);
--- a/gfx/angle/src/compiler/glslang_tab.cpp
+++ b/gfx/angle/src/compiler/glslang_tab.cpp
@@ -733,27 +733,27 @@ static const yytype_uint16 yyrline[] =
      296,   299,   408,   418,   431,   439,   538,   541,   549,   553,
      560,   564,   571,   577,   586,   594,   656,   663,   673,   676,
      686,   696,   717,   718,   719,   724,   725,   734,   746,   747,
      755,   766,   770,   771,   781,   791,   801,   814,   815,   825,
      838,   842,   846,   850,   851,   864,   865,   878,   879,   892,
      893,   910,   911,   924,   925,   926,   927,   928,   932,   935,
      946,   954,   979,   984,   991,  1027,  1030,  1037,  1045,  1066,
     1085,  1096,  1125,  1130,  1140,  1145,  1155,  1158,  1161,  1164,
-    1170,  1177,  1187,  1203,  1221,  1245,  1268,  1272,  1290,  1313,
-    1345,  1365,  1441,  1450,  1473,  1476,  1482,  1490,  1498,  1506,
-    1509,  1516,  1519,  1522,  1528,  1531,  1546,  1550,  1554,  1558,
-    1567,  1572,  1577,  1582,  1587,  1592,  1597,  1602,  1607,  1612,
-    1618,  1624,  1630,  1635,  1640,  1645,  1658,  1671,  1679,  1682,
-    1697,  1728,  1732,  1738,  1746,  1762,  1766,  1770,  1771,  1777,
-    1778,  1779,  1780,  1781,  1785,  1786,  1786,  1786,  1796,  1797,
-    1802,  1805,  1815,  1818,  1824,  1825,  1829,  1837,  1841,  1851,
-    1856,  1873,  1873,  1878,  1878,  1885,  1885,  1893,  1896,  1902,
-    1905,  1911,  1915,  1922,  1929,  1936,  1943,  1954,  1963,  1967,
-    1974,  1977,  1983,  1983
+    1170,  1177,  1187,  1203,  1221,  1245,  1268,  1272,  1290,  1298,
+    1330,  1350,  1426,  1435,  1458,  1461,  1467,  1475,  1483,  1491,
+    1494,  1501,  1504,  1507,  1513,  1516,  1531,  1535,  1539,  1543,
+    1552,  1557,  1562,  1567,  1572,  1577,  1582,  1587,  1592,  1597,
+    1603,  1609,  1615,  1620,  1625,  1630,  1643,  1656,  1664,  1667,
+    1682,  1713,  1717,  1723,  1731,  1747,  1751,  1755,  1756,  1762,
+    1763,  1764,  1765,  1766,  1770,  1771,  1771,  1771,  1781,  1782,
+    1787,  1790,  1800,  1803,  1809,  1810,  1814,  1822,  1826,  1836,
+    1841,  1858,  1858,  1863,  1863,  1870,  1870,  1878,  1881,  1887,
+    1890,  1896,  1900,  1907,  1914,  1921,  1928,  1939,  1948,  1952,
+    1959,  1962,  1968,  1968
 };
 #endif
 
 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
 static const char *const yytname[] =
 {
@@ -3492,37 +3492,22 @@ yyreduce:
         if (variable && symbol)
             symbol->setId(variable->getUniqueId());
     ;}
     break;
 
   case 98:
 
     {
+        context->error((yyvsp[(2) - (4)].lex).line, "unsized array declarations not supported", (yyvsp[(2) - (4)].lex).string->c_str(), "");
+        context->recover();
+
         TIntermSymbol* symbol = context->intermediate.addSymbol(0, *(yyvsp[(2) - (4)].lex).string, TType((yyvsp[(1) - (4)].interm.type)), (yyvsp[(2) - (4)].lex).line);
         (yyval.interm).intermAggregate = context->intermediate.makeAggregate(symbol, (yyvsp[(2) - (4)].lex).line);
-        
-        if (context->structQualifierErrorCheck((yyvsp[(2) - (4)].lex).line, (yyvsp[(1) - (4)].interm.type)))
-            context->recover();
-
-        if (context->nonInitConstErrorCheck((yyvsp[(2) - (4)].lex).line, *(yyvsp[(2) - (4)].lex).string, (yyvsp[(1) - (4)].interm.type)))
-            context->recover();
-
         (yyval.interm).type = (yyvsp[(1) - (4)].interm.type);
-
-        if (context->arrayTypeErrorCheck((yyvsp[(3) - (4)].lex).line, (yyvsp[(1) - (4)].interm.type)) || context->arrayQualifierErrorCheck((yyvsp[(3) - (4)].lex).line, (yyvsp[(1) - (4)].interm.type)))
-            context->recover();
-        else {
-            (yyvsp[(1) - (4)].interm.type).setArray(true);
-            TVariable* variable = 0;
-            if (context->arrayErrorCheck((yyvsp[(3) - (4)].lex).line, *(yyvsp[(2) - (4)].lex).string, (yyvsp[(1) - (4)].interm.type), variable))
-                context->recover();
-            if (variable && symbol)
-                symbol->setId(variable->getUniqueId());
-        }
     ;}
     break;
 
   case 99:
 
     {
         TType type = TType((yyvsp[(1) - (5)].interm.type));
         int size;
--- a/gfx/angle/src/libEGL/Display.cpp
+++ b/gfx/angle/src/libEGL/Display.cpp
@@ -13,18 +13,26 @@
 #include <algorithm>
 #include <vector>
 
 #include "common/debug.h"
 #include "libGLESv2/mathutil.h"
 
 #include "libEGL/main.h"
 
-#define REF_RAST 0        // Can also be enabled by defining FORCE_REF_RAST in the project's predefined macros
-#define ENABLE_D3D9EX 1   // Enables use of the IDirect3D9Ex interface, when available
+// Can also be enabled by defining FORCE_REF_RAST in the project's predefined macros
+#define REF_RAST 0
+
+// The "Debug This Pixel..." feature in PIX often fails when using the
+// D3D9Ex interfaces.  In order to get debug pixel to work on a Vista/Win 7
+// machine, define "ANGLE_ENABLE_D3D9EX=0" in your project file.
+#if !defined(ANGLE_ENABLE_D3D9EX)
+// Enables use of the IDirect3D9Ex interface, when available
+#define ANGLE_ENABLE_D3D9EX 1
+#endif // !defined(ANGLE_ENABLE_D3D9EX)
 
 namespace egl
 {
 Display::Display(HDC deviceContext) : mDc(deviceContext)
 {
     mD3d9Module = NULL;
     
     mD3d9 = NULL;
@@ -65,17 +73,17 @@ bool Display::initialize()
     }
 
     typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT, IDirect3D9Ex**);
     Direct3DCreate9ExFunc Direct3DCreate9ExPtr = reinterpret_cast<Direct3DCreate9ExFunc>(GetProcAddress(mD3d9Module, "Direct3DCreate9Ex"));
 
     // Use Direct3D9Ex if available. Among other things, this version is less
     // inclined to report a lost context, for example when the user switches
     // desktop. Direct3D9Ex is available in Windows Vista and later if suitable drivers are available.
-    if (ENABLE_D3D9EX && Direct3DCreate9ExPtr && SUCCEEDED(Direct3DCreate9ExPtr(D3D_SDK_VERSION, &mD3d9Ex)))
+    if (ANGLE_ENABLE_D3D9EX && Direct3DCreate9ExPtr && SUCCEEDED(Direct3DCreate9ExPtr(D3D_SDK_VERSION, &mD3d9Ex)))
     {
         ASSERT(mD3d9Ex);
         mD3d9Ex->QueryInterface(IID_IDirect3D9, reinterpret_cast<void**>(&mD3d9));
         ASSERT(mD3d9);
     }
     else
     {
         mD3d9 = Direct3DCreate9(D3D_SDK_VERSION);
@@ -530,17 +538,17 @@ EGLSurface Display::createOffscreenSurfa
         return error(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
     }
 
     if (width == 0 || height == 0)
     {
         return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
     }
 
-    if (textureFormat != EGL_NO_TEXTURE && !getNonPow2TextureSupport() && (!gl::isPow2(width) || !gl::isPow2(height)))
+    if (textureFormat != EGL_NO_TEXTURE && !getNonPower2TextureSupport() && (!gl::isPow2(width) || !gl::isPow2(height)))
     {
         return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
     }
 
     if ((textureFormat != EGL_NO_TEXTURE && textureTarget == EGL_NO_TEXTURE) ||
         (textureFormat == EGL_NO_TEXTURE && textureTarget != EGL_NO_TEXTURE))
     {
         return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
@@ -576,16 +584,22 @@ EGLContext Display::createContext(EGLCon
     {
         if (!createDevice())
         {
             return NULL;
         }
     }
     else if (isDeviceLost())   // Lost device
     {
+        // Release surface resources to make the Reset() succeed
+        for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
+        {
+            (*surface)->release();
+        }
+
         if (!resetDevice())
         {
             return NULL;
         }
 
         // Restore any surfaces that may have been lost
         for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
         {
@@ -598,39 +612,24 @@ EGLContext Display::createContext(EGLCon
     gl::Context *context = glCreateContext(config, shareContext);
     mContextSet.insert(context);
 
     return context;
 }
 
 void Display::destroySurface(egl::Surface *surface)
 {
-    if (surface == egl::getCurrentDrawSurface() || surface == egl::getCurrentReadSurface())
-    {
-        surface->setPendingDestroy();
-    }
-    else
-    {
-        delete surface;
-        mSurfaceSet.erase(surface);
-    }
+    delete surface;
+    mSurfaceSet.erase(surface);
 }
 
 void Display::destroyContext(gl::Context *context)
 {
     glDestroyContext(context);
     mContextSet.erase(context);
-
-    if (mContextSet.empty() && mDevice && isDeviceLost())   // Last context of a lost device
-    {
-        for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
-        {
-            (*surface)->release();
-        }	
-    }
 }
 
 bool Display::isInitialized() const
 {
     return mD3d9 != NULL && mConfigSet.size() > 0;
 }
 
 bool Display::isValidConfig(EGLConfig config)
@@ -640,17 +639,17 @@ bool Display::isValidConfig(EGLConfig co
 
 bool Display::isValidContext(gl::Context *context)
 {
     return mContextSet.find(context) != mContextSet.end();
 }
 
 bool Display::isValidSurface(egl::Surface *surface)
 {
-    return mSurfaceSet.find(surface) != mSurfaceSet.end() && !surface->isPendingDestroy();
+    return mSurfaceSet.find(surface) != mSurfaceSet.end();
 }
 
 bool Display::hasExistingWindowSurface(HWND window)
 {
     for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
     {
         if ((*surface)->getWindowHandle() == window)
         {
@@ -787,21 +786,16 @@ bool Display::getLuminanceTextureSupport
 bool Display::getLuminanceAlphaTextureSupport()
 {
     D3DDISPLAYMODE currentDisplayMode;
     mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
 
     return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8L8));
 }
 
-bool Display::getNonPow2TextureSupport()
-{
-    return !(mDeviceCaps.TextureCaps & (D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_NONPOW2CONDITIONAL));
-}
-
 D3DPOOL Display::getBufferPool(DWORD usage) const
 {
     if (mD3d9Ex != NULL)
     {
         return D3DPOOL_DEFAULT;
     }
     else
     {
@@ -881,9 +875,16 @@ bool Display::getVertexTextureSupport() 
     D3DDISPLAYMODE currentDisplayMode;
     mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
 
     HRESULT result = mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_VERTEXTEXTURE, D3DRTYPE_TEXTURE, D3DFMT_R16F);
 
     return SUCCEEDED(result);
 }
 
+bool Display::getNonPower2TextureSupport() const
+{
+    return !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_POW2) &&
+           !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2) &&
+           !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL);
 }
+
+}
--- a/gfx/angle/src/libEGL/Display.h
+++ b/gfx/angle/src/libEGL/Display.h
@@ -63,18 +63,18 @@ class Display
     bool isDeviceLost();
     virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray);
     virtual bool getCompressedTextureSupport();
     virtual bool getEventQuerySupport();
     virtual bool getFloatTextureSupport(bool *filtering, bool *renderable);
     virtual bool getHalfFloatTextureSupport(bool *filtering, bool *renderable);
     virtual bool getLuminanceTextureSupport();
     virtual bool getLuminanceAlphaTextureSupport();
-    virtual bool getNonPow2TextureSupport();
     virtual bool getVertexTextureSupport() const;
+    virtual bool getNonPower2TextureSupport() const;
     virtual D3DPOOL getBufferPool(DWORD usage) const;
 
     bool isD3d9ExDevice() { return mD3d9Ex != NULL; }
     const char *getExtensionString() const;
 
   private:
     DISALLOW_COPY_AND_ASSIGN(Display);
 
--- a/gfx/angle/src/libEGL/Makefile.in
+++ b/gfx/angle/src/libEGL/Makefile.in
@@ -134,9 +134,12 @@ CPPSRCS += \
   main.cpp \
   Surface.cpp \
   $(NULL)
 
 DEFFILE = $(srcdir)/libEGL.def
 
 include $(topsrcdir)/config/rules.mk
 
-EXTRA_DSO_LDOPTS = "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/d3d9.lib" "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/dxguid.lib" $(DIST)/lib/libGLESv2.lib
+EXTRA_DSO_LDOPTS = "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/d3d9.lib" \
+                   "$(MOZ_DIRECTX_SDK_PATH)/lib/x86/dxguid.lib" \
+		   "dwmapi.lib" \
+		   $(DIST)/lib/libGLESv2.lib
--- a/gfx/angle/src/libEGL/Surface.cpp
+++ b/gfx/angle/src/libEGL/Surface.cpp
@@ -13,16 +13,18 @@
 #include "libEGL/Surface.h"
 
 #include "common/debug.h"
 #include "libGLESv2/Texture.h"
 
 #include "libEGL/main.h"
 #include "libEGL/Display.h"
 
+#include <dwmapi.h>
+
 namespace egl
 {
 Surface::Surface(Display *display, const Config *config, HWND window) 
     : mDisplay(display), mConfig(config), mWindow(window)
 {
     mSwapChain = NULL;
     mDepthStencil = NULL;
     mRenderTarget = NULL;
@@ -33,18 +35,16 @@ Surface::Surface(Display *display, const
     mTextureTarget = EGL_NO_TEXTURE;
 
     mPixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING);   // FIXME: Determine actual pixel aspect ratio
     mRenderBuffer = EGL_BACK_BUFFER;
     mSwapBehavior = EGL_BUFFER_PRESERVED;
     mSwapInterval = -1;
     setSwapInterval(1);
 
-    mIsPendingDestroy = false;
-
     subclassWindow();
 }
 
 Surface::Surface(Display *display, const Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureType)
     : mDisplay(display), mWindow(NULL), mConfig(config), mShareHandle(shareHandle), mWidth(width), mHeight(height)
 {
     mSwapChain = NULL;
     mDepthStencil = NULL;
@@ -55,30 +55,50 @@ Surface::Surface(Display *display, const
     mTextureFormat = textureFormat;
     mTextureTarget = textureType;
 
     mPixelAspectRatio = (EGLint)(1.0 * EGL_DISPLAY_SCALING);   // FIXME: Determine actual pixel aspect ratio
     mRenderBuffer = EGL_BACK_BUFFER;
     mSwapBehavior = EGL_BUFFER_PRESERVED;
     mSwapInterval = -1;
     setSwapInterval(1);
-
-    mIsPendingDestroy = false;
 }
 
 Surface::~Surface()
 {
     unsubclassWindow();
     release();
 }
 
 bool Surface::initialize()
 {
     ASSERT(!mSwapChain && !mOffscreenTexture && !mDepthStencil);
-    return resetSwapChain();
+
+    if (!resetSwapChain())
+      return false;
+
+    // Modify present parameters for this window, if we are composited,
+    // to minimize the amount of queuing done by DWM between our calls to
+    // present and the actual screen.
+    if (mWindow && (LOWORD(GetVersion()) >= 0x60)) {
+      BOOL isComposited;
+      HRESULT result = DwmIsCompositionEnabled(&isComposited);
+      if (SUCCEEDED(result) && isComposited) {
+        DWM_PRESENT_PARAMETERS presentParams;
+        memset(&presentParams, 0, sizeof(presentParams));
+        presentParams.cbSize = sizeof(DWM_PRESENT_PARAMETERS);
+        presentParams.cBuffer = 2;
+
+        result = DwmSetPresentParameters(mWindow, &presentParams);
+        if (FAILED(result))
+          ERR("Unable to set present parameters: %081X", result);
+      }
+    }
+
+    return true;
 }
 
 void Surface::release()
 {
     if (mSwapChain)
     {
         mSwapChain->Release();
         mSwapChain = NULL;
@@ -140,26 +160,47 @@ bool Surface::resetSwapChain(int backbuf
     // Evict all non-render target textures to system memory and release all resources
     // before reallocating them to free up as much video memory as possible.
     device->EvictManagedResources();
     release();
 
     D3DPRESENT_PARAMETERS presentParameters = {0};
     HRESULT result;
 
+    bool useFlipEx = (LOWORD(GetVersion()) >= 0x61) && mDisplay->isD3d9ExDevice();
+
+    // FlipEx causes unseemly stretching when resizing windows AND when one
+    // draws outside of the WM_PAINT callback. While this is seldom a problem in
+    // single process applications, it is particuarly noticeable in multiprocess
+    // applications. Therefore, if the creator process of our window is not in
+    // the current process, disable use of FlipEx.
+    DWORD windowPID;
+    GetWindowThreadProcessId(mWindow, &windowPID);
+    if(windowPID != GetCurrentProcessId())
+    useFlipEx = false;
+
     presentParameters.AutoDepthStencilFormat = mConfig->mDepthStencilFormat;
+    // We set BackBufferCount = 1 even when we use D3DSWAPEFFECT_FLIPEX.
+    // We do this because DirectX docs are a bit vague whether to set this to 1
+    // or 2. The runtime seems to accept 1, so we speculate that either it is
+    // forcing it to 2 without telling us, or better, doing something smart
+    // behind the scenes knowing that we don't need more.
     presentParameters.BackBufferCount = 1;
     presentParameters.BackBufferFormat = mConfig->mRenderTargetFormat;
     presentParameters.EnableAutoDepthStencil = FALSE;
     presentParameters.Flags = 0;
     presentParameters.hDeviceWindow = getWindowHandle();
     presentParameters.MultiSampleQuality = 0;                  // FIXME: Unimplemented
     presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE;   // FIXME: Unimplemented
     presentParameters.PresentationInterval = mPresentInterval;
-    presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
+    // Use flipEx on Win7 or greater.
+    if(useFlipEx)
+      presentParameters.SwapEffect = D3DSWAPEFFECT_FLIPEX;
+    else
+      presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
     presentParameters.Windowed = TRUE;
     presentParameters.BackBufferWidth = backbufferWidth;
     presentParameters.BackBufferHeight = backbufferHeight;
 
     if (mWindow)
     {
         result = device->CreateAdditionalSwapChain(&presentParameters, &mSwapChain);
     } else {
@@ -215,65 +256,81 @@ HWND Surface::getWindowHandle()
 {
     return mWindow;
 }
 
 
 #define kSurfaceProperty _TEXT("Egl::SurfaceOwner")
 #define kParentWndProc _TEXT("Egl::SurfaceParentWndProc")
 
-static LRESULT CALLBACK SurfaceWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
-  if (message == WM_SIZE) {
+static LRESULT CALLBACK SurfaceWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
+{
+  if (message == WM_SIZE)
+  {
       Surface* surf = reinterpret_cast<Surface*>(GetProp(hwnd, kSurfaceProperty));
-      if(surf) {
-        surf->checkForOutOfDateSwapChain();
+      if(surf)
+      {
+          surf->checkForOutOfDateSwapChain();
       }
   }
   WNDPROC prevWndFunc = reinterpret_cast<WNDPROC >(GetProp(hwnd, kParentWndProc));
   return CallWindowProc(prevWndFunc, hwnd, message, wparam, lparam);
 }
 
 void Surface::subclassWindow()
 {
-  if (!mWindow)
-    return;
+    if (!mWindow)
+    {
+        return;
+    }
+
+    DWORD processId;
+    DWORD threadId = GetWindowThreadProcessId(mWindow, &processId);
+    if (processId != GetCurrentProcessId() || threadId != GetCurrentThreadId())
+    {
+        return;
+    }
 
-  SetLastError(0);
-  LONG oldWndProc = SetWindowLong(mWindow, GWL_WNDPROC, reinterpret_cast<LONG>(SurfaceWindowProc));
-  if(oldWndProc == 0 && GetLastError() != ERROR_SUCCESS) {
-    mWindowSubclassed = false;
-    return;
-  }
+    SetLastError(0);
+    LONG oldWndProc = SetWindowLong(mWindow, GWL_WNDPROC, reinterpret_cast<LONG>(SurfaceWindowProc));
+    if(oldWndProc == 0 && GetLastError() != ERROR_SUCCESS)
+    {
+        mWindowSubclassed = false;
+        return;
+    }
 
-  SetProp(mWindow, kSurfaceProperty, reinterpret_cast<HANDLE>(this));
-  SetProp(mWindow, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc));
-  mWindowSubclassed = true;
+    SetProp(mWindow, kSurfaceProperty, reinterpret_cast<HANDLE>(this));
+    SetProp(mWindow, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc));
+    mWindowSubclassed = true;
 }
 
 void Surface::unsubclassWindow()
 {
-  if(!mWindowSubclassed)
-    return;
+    if(!mWindowSubclassed)
+    {
+        return;
+    }
 
-  // un-subclass
-  LONG parentWndFunc = reinterpret_cast<LONG>(GetProp(mWindow, kParentWndProc));
+    // un-subclass
+    LONG parentWndFunc = reinterpret_cast<LONG>(GetProp(mWindow, kParentWndProc));
 
-  // Check the windowproc is still SurfaceWindowProc.
-  // If this assert fails, then it is likely the application has subclassed the
-  // hwnd as well and did not unsubclass before destroying its EGL context. The
-  // application should be modified to either subclass before initializing the
-  // EGL context, or to unsubclass before destroying the EGL context.
-  if(parentWndFunc) {
-    LONG prevWndFunc = SetWindowLong(mWindow, GWL_WNDPROC, parentWndFunc);
-    ASSERT(prevWndFunc == reinterpret_cast<LONG>(SurfaceWindowProc));
-  }
+    // Check the windowproc is still SurfaceWindowProc.
+    // If this assert fails, then it is likely the application has subclassed the
+    // hwnd as well and did not unsubclass before destroying its EGL context. The
+    // application should be modified to either subclass before initializing the
+    // EGL context, or to unsubclass before destroying the EGL context.
+    if(parentWndFunc)
+    {
+        LONG prevWndFunc = SetWindowLong(mWindow, GWL_WNDPROC, parentWndFunc);
+        ASSERT(prevWndFunc == reinterpret_cast<LONG>(SurfaceWindowProc));
+    }
 
-  RemoveProp(mWindow, kSurfaceProperty);
-  RemoveProp(mWindow, kParentWndProc);
-  mWindowSubclassed = false;
+    RemoveProp(mWindow, kSurfaceProperty);
+    RemoveProp(mWindow, kParentWndProc);
+    mWindowSubclassed = false;
 }
 
 bool Surface::checkForOutOfDateSwapChain()
 {
     RECT client;
     if (!GetClientRect(getWindowHandle(), &client))
     {
         ASSERT(false);
@@ -308,31 +365,30 @@ DWORD Surface::convertInterval(EGLint in
       case 3: return D3DPRESENT_INTERVAL_THREE;
       case 4: return D3DPRESENT_INTERVAL_FOUR;
       default: UNREACHABLE();
     }
 
     return D3DPRESENT_INTERVAL_DEFAULT;
 }
 
-
 bool Surface::swap()
 {
     if (mSwapChain)
     {
         mDisplay->endScene();
 
         HRESULT result = mSwapChain->Present(NULL, NULL, NULL, NULL, 0);
 
         if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DRIVERINTERNALERROR)
         {
             return error(EGL_BAD_ALLOC, false);
         }
 
-        if (result == D3DERR_DEVICELOST)
+        if (result == D3DERR_DEVICELOST || result == D3DERR_DEVICEHUNG || result == D3DERR_DEVICEREMOVED)
         {
             return error(EGL_CONTEXT_LOST, false);
         }
 
         ASSERT(SUCCEEDED(result));
 
         checkForOutOfDateSwapChain();
     }
@@ -414,18 +470,9 @@ gl::Texture2D *Surface::getBoundTexture(
 {
     return mTexture;
 }
 
 D3DFORMAT Surface::getFormat() const
 {
     return mConfig->mRenderTargetFormat;
 }
-
-void Surface::setPendingDestroy() {
-    mIsPendingDestroy = true;
 }
-
-bool Surface::isPendingDestroy() const {
-    return mIsPendingDestroy;
-}
-
-}
--- a/gfx/angle/src/libEGL/Surface.h
+++ b/gfx/angle/src/libEGL/Surface.h
@@ -56,30 +56,26 @@ class Surface
 
     virtual EGLenum getTextureFormat() const;
     virtual EGLenum getTextureTarget() const;
     virtual D3DFORMAT getFormat() const;
 
     virtual void setBoundTexture(gl::Texture2D *texture);
     virtual gl::Texture2D *getBoundTexture() const;
 
-    void setPendingDestroy();
-    bool isPendingDestroy() const;
-
 private:
     DISALLOW_COPY_AND_ASSIGN(Surface);
 
     Display *const mDisplay;
     IDirect3DSwapChain9 *mSwapChain;
     IDirect3DSurface9 *mDepthStencil;
     IDirect3DSurface9* mRenderTarget;
     IDirect3DTexture9* mOffscreenTexture;
 
     HANDLE mShareHandle;
-    bool mIsPendingDestroy;
 
     void subclassWindow();
     void unsubclassWindow();
     bool resetSwapChain(int backbufferWidth, int backbufferHeight);
     static DWORD convertInterval(EGLint interval);
 
     const HWND mWindow;            // Window that the surface is created for.
     bool mWindowSubclassed;        // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking
--- a/gfx/angle/src/libEGL/libEGL.cpp
+++ b/gfx/angle/src/libEGL/libEGL.cpp
@@ -931,28 +931,16 @@ EGLBoolean __stdcall eglMakeCurrent(EGLD
         egl::Surface* previousRead = static_cast<egl::Surface*>(egl::getCurrentReadSurface());
 
         egl::setCurrentDisplay(dpy);
         egl::setCurrentDrawSurface(draw);
         egl::setCurrentReadSurface(read);
 
         glMakeCurrent(context, display, static_cast<egl::Surface*>(draw));
 
-        // If the previous surfaces are still current, this might just flag
-        // them as pending destruction again, deferring destruction to a future
-        // eglMakeCurrent or eglTerminate call.
-        if (previousDraw && previousDraw->isPendingDestroy())
-        {
-            eglDestroySurface(dpy, previousDraw);
-        }
-        if (previousRead && previousRead != previousDraw && previousRead->isPendingDestroy())
-        {
-            eglDestroySurface(dpy, previousRead);
-        }
-
         return success(EGL_TRUE);
     }
     catch(std::bad_alloc&)
     {
         return error(EGL_BAD_ALLOC, EGL_FALSE);
     }
 
     return EGL_FALSE;
--- a/gfx/angle/src/libEGL/libEGL.vcproj
+++ b/gfx/angle/src/libEGL/libEGL.vcproj
@@ -1,92 +1,266 @@
 <?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject ProjectType="Visual C++" Version="8.00" Name="libEGL" ProjectGUID="{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}" RootNamespace="libEGL" Keyword="Win32Proj" TargetFrameworkVersion="131072">
-  <Platforms>
-    <Platform Name="Win32" />
-  </Platforms>
-  <ToolFiles>
-  </ToolFiles>
-  <Configurations>
-    <Configuration Name="Debug|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" CharacterSet="1">
-      <Tool Name="VCPreBuildEventTool" />
-      <Tool Name="VCCustomBuildTool" />
-      <Tool Name="VCXMLDataGeneratorTool" />
-      <Tool Name="VCWebServiceProxyGeneratorTool" />
-      <Tool Name="VCMIDLTool" />
-      <Tool Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="$(ProjectDir)/..; $(ProjectDir)/../../include" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" UsePrecompiledHeader="0" WarningLevel="3" Detect64BitPortabilityProblems="false" DebugInformationFormat="4" />
-      <Tool Name="VCManagedResourceCompilerTool" />
-      <Tool Name="VCResourceCompilerTool" />
-      <Tool Name="VCPreLinkEventTool" />
-      <Tool Name="VCLinkerTool" AdditionalDependencies="d3d9.lib dxguid.lib" LinkIncremental="2" ModuleDefinitionFile="libEGL.def" GenerateDebugInformation="true" SubSystem="2" RandomizedBaseAddress="1" DataExecutionPrevention="0" TargetMachine="1" />
-      <Tool Name="VCALinkTool" />
-      <Tool Name="VCManifestTool" />
-      <Tool Name="VCXDCMakeTool" />
-      <Tool Name="VCBscMakeTool" />
-      <Tool Name="VCFxCopTool" />
-      <Tool Name="VCAppVerifierTool" />
-      <Tool Name="VCPostBuildEventTool" CommandLine="@echo on&#xD;&#xA;mkdir &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#xD;&#xA;copy &quot;$(OutDir)\libEGL.dll&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#xD;&#xA;copy &quot;$(OutDir)\libEGL.lib&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#xD;&#xA;@echo off&#xD;&#xA;" />
-    </Configuration>
-    <Configuration Name="Release|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" CharacterSet="1" WholeProgramOptimization="1">
-      <Tool Name="VCPreBuildEventTool" />
-      <Tool Name="VCCustomBuildTool" />
-      <Tool Name="VCXMLDataGeneratorTool" />
-      <Tool Name="VCWebServiceProxyGeneratorTool" />
-      <Tool Name="VCMIDLTool" />
-      <Tool Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="2" AdditionalIncludeDirectories="$(ProjectDir)/..; $(ProjectDir)/../../include" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0" RuntimeLibrary="0" UsePrecompiledHeader="0" WarningLevel="3" Detect64BitPortabilityProblems="false" DebugInformationFormat="3" />
-      <Tool Name="VCManagedResourceCompilerTool" />
-      <Tool Name="VCResourceCompilerTool" />
-      <Tool Name="VCPreLinkEventTool" />
-      <Tool Name="VCLinkerTool" AdditionalDependencies="d3d9.lib dxguid.lib" LinkIncremental="1" ModuleDefinitionFile="libEGL.def" GenerateDebugInformation="true" SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" RandomizedBaseAddress="1" DataExecutionPrevention="0" TargetMachine="1" />
-      <Tool Name="VCALinkTool" />
-      <Tool Name="VCManifestTool" />
-      <Tool Name="VCXDCMakeTool" />
-      <Tool Name="VCBscMakeTool" />
-      <Tool Name="VCFxCopTool" />
-      <Tool Name="VCAppVerifierTool" />
-      <Tool Name="VCPostBuildEventTool" CommandLine="@echo on&#xD;&#xA;mkdir &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#xD;&#xA;copy &quot;$(OutDir)\libEGL.dll&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#xD;&#xA;copy &quot;$(OutDir)\libEGL.lib&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#xD;&#xA;@echo off&#xD;&#xA;" />
-    </Configuration>
-  </Configurations>
-  <References>
-  </References>
-  <Files>
-    <Filter Name="Source Files" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
-      <File RelativePath=".\Config.cpp">
-      </File>
-      <File RelativePath="..\Common\debug.cpp">
-      </File>
-      <File RelativePath=".\Display.cpp">
-      </File>
-      <File RelativePath=".\libEGL.cpp">
-      </File>
-      <File RelativePath=".\main.cpp">
-      </File>
-      <File RelativePath=".\Surface.cpp">
-      </File>
-    </Filter>
-    <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
-      <File RelativePath=".\Config.h">
-      </File>
-      <File RelativePath=".\Display.h">
-      </File>
-      <File RelativePath="..\..\include\EGL\egl.h">
-      </File>
-      <File RelativePath="..\..\include\EGL\eglext.h">
-      </File>
-      <File RelativePath="..\..\include\EGL\eglplatform.h">
-      </File>
-      <File RelativePath=".\main.h">
-      </File>
-      <File RelativePath=".\resource.h">
-      </File>
-      <File RelativePath=".\Surface.h">
-      </File>
-      <File RelativePath="..\common\version.h">
-      </File>
-    </Filter>
-    <File RelativePath=".\libEGL.def">
-    </File>
-    <File RelativePath=".\libEGL.rc">
-    </File>
-  </Files>
-  <Globals>
-  </Globals>
-</VisualStudioProject>
\ No newline at end of file
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="libEGL"
+	ProjectGUID="{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}"
+	RootNamespace="libEGL"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="$(ProjectDir)/..; $(ProjectDir)/../../include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="false"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="d3d9.lib dxguid.lib dwmapi.lib"
+				LinkIncremental="2"
+				ModuleDefinitionFile="libEGL.def"
+				DelayLoadDLLs="dwmapi.dll"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="@echo on&#x0D;&#x0A;mkdir &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\libEGL.dll&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\libEGL.lib&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;@echo off&#x0D;&#x0A;"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="2"
+				AdditionalIncludeDirectories="$(ProjectDir)/..; $(ProjectDir)/../../include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0"
+				RuntimeLibrary="0"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="false"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="d3d9.lib dxguid.lib dwmapi.lib"
+				LinkIncremental="1"
+				ModuleDefinitionFile="libEGL.def"
+				DelayLoadDLLs="dwmapi.lib"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="@echo on&#x0D;&#x0A;mkdir &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\libEGL.dll&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\libEGL.lib&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;@echo off&#x0D;&#x0A;"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath=".\Config.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\Common\debug.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\Display.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\libEGL.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\main.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\Surface.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath=".\Config.h"
+				>
+			</File>
+			<File
+				RelativePath=".\Display.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\include\EGL\egl.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\include\EGL\eglext.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\include\EGL\eglplatform.h"
+				>
+			</File>
+			<File
+				RelativePath=".\main.h"
+				>
+			</File>
+			<File
+				RelativePath=".\resource.h"
+				>
+			</File>
+			<File
+				RelativePath=".\Surface.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\version.h"
+				>
+			</File>
+		</Filter>
+		<File
+			RelativePath=".\libEGL.def"
+			>
+		</File>
+		<File
+			RelativePath=".\libEGL.rc"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
--- a/gfx/angle/src/libGLESv2/Context.cpp
+++ b/gfx/angle/src/libGLESv2/Context.cpp
@@ -238,16 +238,17 @@ void Context::makeCurrent(egl::Display *
         mDeviceCaps = display->getDeviceCaps();
 
         mVertexDataManager = new VertexDataManager(this, device);
         mIndexDataManager = new IndexDataManager(this, device);
         mBlit = new Blit(this);
 
         mSupportsShaderModel3 = mDeviceCaps.PixelShaderVersion == D3DPS_VERSION(3, 0);
         mSupportsVertexTexture = display->getVertexTextureSupport();
+        mSupportsNonPower2Texture = display->getNonPower2TextureSupport();
 
         mMaxTextureDimension = std::min(std::min((int)mDeviceCaps.MaxTextureWidth, (int)mDeviceCaps.MaxTextureHeight),
                                         (int)gl::IMPLEMENTATION_MAX_TEXTURE_SIZE);
         mMaxCubeTextureDimension = std::min(mMaxTextureDimension, (int)gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE);
         mMaxRenderbufferDimension = mMaxTextureDimension;
         mMaxTextureLevel = log2(mMaxTextureDimension) + 1;
         TRACE("MaxTextureDimension=%d, MaxCubeTextureDimension=%d, MaxRenderbufferDimension=%d, MaxTextureLevel=%d",
               mMaxTextureDimension, mMaxCubeTextureDimension, mMaxRenderbufferDimension, mMaxTextureLevel);
@@ -1863,16 +1864,17 @@ void Context::applyState(GLenum drawMode
                                    es2dx::ConvertStencilOp(mState.stencilBackPassDepthPass));
         }
         else
         {
             device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
         }
 
         mStencilStateDirty = false;
+        mFrontFaceDirty = false;
     }
 
     if (mMaskStateDirty)
     {
         device->SetRenderState(D3DRS_COLORWRITEENABLE, es2dx::ConvertColorMask(mState.colorMaskRed, mState.colorMaskGreen, 
                                                                                mState.colorMaskBlue, mState.colorMaskAlpha));
         device->SetRenderState(D3DRS_ZWRITEENABLE, mState.depthMask ? TRUE : FALSE);
 
@@ -1897,71 +1899,62 @@ void Context::applyState(GLenum drawMode
             device->SetRenderState(D3DRS_DEPTHBIAS, 0);
         }
 
         mPolygonOffsetStateDirty = false;
     }
 
     if (mSampleStateDirty)
     {
-        if (framebufferObject->isMultisample())
+        if (mState.sampleAlphaToCoverage)
         {
-            if (mState.sampleAlphaToCoverage)
-            {
-                FIXME("Sample alpha to coverage is unimplemented.");
-            }
-
-            device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
-            if (mState.sampleCoverage)
+            FIXME("Sample alpha to coverage is unimplemented.");
+        }
+
+        device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
+        if (mState.sampleCoverage)
+        {
+            unsigned int mask = 0;
+            if (mState.sampleCoverageValue != 0)
             {
-                unsigned int mask = 0;
-                if (mState.sampleCoverageValue != 0)
+                float threshold = 0.5f;
+
+                for (int i = 0; i < framebufferObject->getSamples(); ++i)
                 {
-                    float threshold = 0.5f;
-
-                    for (int i = 0; i < framebufferObject->getSamples(); ++i)
+                    mask <<= 1;
+
+                    if ((i + 1) * mState.sampleCoverageValue >= threshold)
                     {
-                        mask <<= 1;
-
-                        if ((i + 1) * mState.sampleCoverageValue >= threshold)
-                        {
-                            threshold += 1.0f;
-                            mask |= 1;
-                        }
+                        threshold += 1.0f;
+                        mask |= 1;
                     }
                 }
-                
-                if (mState.sampleCoverageInvert)
-                {
-                    mask = ~mask;
-                }
-
-                device->SetRenderState(D3DRS_MULTISAMPLEMASK, mask);
             }
-            else
+            
+            if (mState.sampleCoverageInvert)
             {
-                device->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
+                mask = ~mask;
             }
+
+            device->SetRenderState(D3DRS_MULTISAMPLEMASK, mask);
         }
         else
         {
-            device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE);
+            device->SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
         }
 
         mSampleStateDirty = false;
     }
 
     if (mDitherStateDirty)
     {
         device->SetRenderState(D3DRS_DITHERENABLE, mState.dither ? TRUE : FALSE);
 
         mDitherStateDirty = false;
     }
-
-    mFrontFaceDirty = false;
 }
 
 GLenum Context::applyVertexBuffer(GLint first, GLsizei count)
 {
     TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS];
 
     GLenum err = mVertexDataManager->prepareVertexData(first, count, attributes);
     if (err != GL_NO_ERROR)
@@ -3093,16 +3086,21 @@ bool Context::supportsLuminanceAlphaText
     return mSupportsLuminanceAlphaTextures;
 }
 
 bool Context::supports32bitIndices() const
 {
     return mSupports32bitIndices;
 }
 
+bool Context::supportsNonPower2Texture() const
+{
+    return mSupportsNonPower2Texture;
+}
+
 void Context::detachBuffer(GLuint buffer)
 {
     // [OpenGL ES 2.0.24] section 2.9 page 22:
     // If a buffer object is deleted while it is bound, all bindings to that object in the current context
     // (i.e. in the thread that called Delete-Buffers) are reset to zero.
 
     if (mState.arrayBuffer.id() == buffer)
     {
@@ -3330,16 +3328,21 @@ void Context::initExtensionString()
         mExtensionString += "GL_ANGLE_framebuffer_multisample ";
     }
 
     if (supports32bitIndices())
     {
         mExtensionString += "GL_OES_element_index_uint ";
     }
 
+    if (supportsNonPower2Texture())
+    {
+        mExtensionString += "GL_OES_texture_npot ";
+    }
+
     std::string::size_type end = mExtensionString.find_last_not_of(' ');
     if (end != std::string::npos)
     {
         mExtensionString.resize(end+1);
     }
 }
 
 const char *Context::getExtensionString() const
--- a/gfx/angle/src/libGLESv2/Context.h
+++ b/gfx/angle/src/libGLESv2/Context.h
@@ -442,16 +442,17 @@ class Context
     bool supportsFloatLinearFilter() const;
     bool supportsFloatRenderableTextures() const;
     bool supportsHalfFloatTextures() const;
     bool supportsHalfFloatLinearFilter() const;
     bool supportsHalfFloatRenderableTextures() const;
     bool supportsLuminanceTextures() const;
     bool supportsLuminanceAlphaTextures() const;
     bool supports32bitIndices() const;
+    bool supportsNonPower2Texture() const;
 
     void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 
                          GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
                          GLbitfield mask);
 
     Blit *getBlitter() { return mBlit; }
 
     const D3DCAPS9 &getDeviceCaps() { return mDeviceCaps; }
@@ -518,16 +519,17 @@ class Context
     unsigned int mAppliedProgramSerial;
     unsigned int mAppliedRenderTargetSerial;
     unsigned int mAppliedDepthbufferSerial;
     unsigned int mAppliedStencilbufferSerial;
     bool mDepthStencilInitialized;
 
     bool mSupportsShaderModel3;
     bool mSupportsVertexTexture;
+    bool mSupportsNonPower2Texture;
     int  mMaxRenderbufferDimension;
     int  mMaxTextureDimension;
     int  mMaxCubeTextureDimension;
     int  mMaxTextureLevel;
     std::map<D3DFORMAT, bool *> mMultiSampleSupport;
     GLsizei mMaxSupportedSamples;
     bool mSupportsEventQueries;
     bool mSupportsCompressedTextures;
--- a/gfx/angle/src/libGLESv2/Framebuffer.cpp
+++ b/gfx/angle/src/libGLESv2/Framebuffer.cpp
@@ -263,33 +263,16 @@ bool Framebuffer::hasStencil()
         {
             return stencilbufferObject->getStencilSize() > 0;
         }
     }
 
     return false;
 }
 
-bool Framebuffer::isMultisample()
-{
-    // If the framebuffer is not complete, attachment samples may be mismatched, and it
-    // cannot be used as a multisample framebuffer. If it is complete, it is required to
-    // have a color attachment, and all its attachments must have the same number of samples,
-    // so the number of samples for the colorbuffer will indicate whether the framebuffer is
-    // multisampled.
-    if (completeness() == GL_FRAMEBUFFER_COMPLETE && getColorbuffer()->getSamples() > 0)
-    {
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
 GLenum Framebuffer::completeness()
 {
     int width = 0;
     int height = 0;
     int samples = -1;
 
     if (mColorbufferType != GL_NONE)
     {
--- a/gfx/angle/src/libGLESv2/Framebuffer.h
+++ b/gfx/angle/src/libGLESv2/Framebuffer.h
@@ -54,17 +54,16 @@ class Framebuffer
     GLenum getDepthbufferType();
     GLenum getStencilbufferType();
 
     GLuint getColorbufferHandle();
     GLuint getDepthbufferHandle();
     GLuint getStencilbufferHandle();
 
     bool hasStencil();
-    bool isMultisample();
     int getSamples();
 
     virtual GLenum completeness();
 
   protected:
     GLenum mColorbufferType;
     BindingPointer<Renderbuffer> mColorbufferPointer;
 
--- a/gfx/angle/src/libGLESv2/Program.cpp
+++ b/gfx/angle/src/libGLESv2/Program.cpp
@@ -10,16 +10,18 @@
 #include "libGLESv2/Program.h"
 
 #include "common/debug.h"
 
 #include "libGLESv2/main.h"
 #include "libGLESv2/Shader.h"
 #include "libGLESv2/utilities.h"
 
+#include <string>
+
 #if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL)
 #define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL3
 #endif
 
 namespace gl
 {
 unsigned int Program::mCurrentSerial = 1;
 
@@ -992,17 +994,17 @@ ID3D10Blob *Program::compileToBinary(con
     ID3D10Blob *binary = NULL;
     ID3D10Blob *errorMessage = NULL;
     result = D3DCompile(hlsl, strlen(hlsl), NULL, NULL, NULL, "main", profile, flags, 0, &binary, &errorMessage);
 
     if (errorMessage)
     {
         const char *message = (const char*)errorMessage->GetBufferPointer();
 
-        appendToInfoLog("%s\n", message);
+        appendToInfoLogSanitized(message);
         TRACE("\n%s", hlsl);
         TRACE("\n%s", message);
 
         errorMessage->Release();
         errorMessage = NULL;
     }
 
 
@@ -2439,16 +2441,45 @@ bool Program::applyUniform4iv(GLint loca
         mConstantTableVS->SetVectorArray(device, constantVS, vector, count);
     }
 
     delete [] vector;
 
     return true;
 }
 
+
+// append a santized message to the program info log.
+// The D3D compiler includes the current working directory
+// in some of the warning or error messages, so lets remove
+// any occurrances of those that we find in the log.
+void Program::appendToInfoLogSanitized(const char *message)
+{
+    std::string msg(message);
+    CHAR path[MAX_PATH] = "";
+    size_t len;
+
+    len = GetCurrentDirectoryA(MAX_PATH, path);
+    if (len > 0 && len < MAX_PATH)
+    {
+        size_t found;
+        do {
+            found = msg.find(path);
+            if (found != std::string::npos)
+            {
+                // the +1 here is intentional so that we remove
+                // the trailing '\' that occurs after the path
+                msg.erase(found, len+1);
+            }
+        } while (found != std::string::npos);
+    }
+
+    appendToInfoLog("%s\n", msg.c_str());
+}
+
 void Program::appendToInfoLog(const char *format, ...)
 {
     if (!format)
     {
         return;
     }
 
     char info[1024];
--- a/gfx/angle/src/libGLESv2/Program.h
+++ b/gfx/angle/src/libGLESv2/Program.h
@@ -156,16 +156,17 @@ class Program
     bool applyUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value);
     bool applyUniform1iv(GLint location, GLsizei count, const GLint *v);
     bool applyUniform2iv(GLint location, GLsizei count, const GLint *v);
     bool applyUniform3iv(GLint location, GLsizei count, const GLint *v);
     bool applyUniform4iv(GLint location, GLsizei count, const GLint *v);
 
     void getConstantHandles(Uniform *targetUniform, D3DXHANDLE *constantPS, D3DXHANDLE *constantVS);
 
+    void appendToInfoLogSanitized(const char *message);
     void appendToInfoLog(const char *info, ...);
     void resetInfoLog();
 
     static std::string decorate(const std::string &string);     // Prepend an underscore
     static std::string undecorate(const std::string &string);   // Remove leading underscore
 
     static unsigned int issueSerial();
 
--- a/gfx/angle/src/libGLESv2/Texture.cpp
+++ b/gfx/angle/src/libGLESv2/Texture.cpp
@@ -1243,17 +1243,17 @@ void Texture::resetDirty()
 
 unsigned int Texture::getSerial() const
 {
     return mSerial;
 }
 
 GLint Texture::creationLevels(GLsizei width, GLsizei height, GLint maxlevel) const
 {
-    if (isPow2(width) && isPow2(height))
+    if ((isPow2(width) && isPow2(height)) || getContext()->supportsNonPower2Texture())
     {
         return maxlevel;
     }
     else
     {
         // OpenGL ES 2.0 without GL_OES_texture_npot does not permit NPOT mipmaps.
         return 1;
     }
@@ -1368,16 +1368,18 @@ void Texture2D::redefineTexture(GLint le
             mIsRenderable = false;
         }
 
         if (mSurface)
         {
             mSurface->setBoundTexture(NULL);
             mSurface = NULL;
         }
+
+        mColorbufferProxy.set(NULL);
     }
 }
 
 void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
 {
     redefineTexture(level, format, width, height, type, false);
 
     Texture::setImage(unpackAlignment, pixels, &mImageArray[level]);
@@ -1595,27 +1597,35 @@ bool Texture2D::isComplete() const
         (getInternalFormat() == GL_HALF_FLOAT_OES && !getContext()->supportsHalfFloatLinearFilter()))
     {
         if (mMagFilter != GL_NEAREST || (mMinFilter != GL_NEAREST && mMinFilter != GL_NEAREST_MIPMAP_NEAREST))
         {
             return false;
         }
     }
 
-    if ((getWrapS() != GL_CLAMP_TO_EDGE && !isPow2(width))
-        || (getWrapT() != GL_CLAMP_TO_EDGE && !isPow2(height)))
+    bool npot = getContext()->supportsNonPower2Texture();
+
+    if (!npot)
     {
-        return false;
+        if ((getWrapS() != GL_CLAMP_TO_EDGE && !isPow2(width)) ||
+            (getWrapT() != GL_CLAMP_TO_EDGE && !isPow2(height)))
+        {
+            return false;
+        }
     }
 
     if (mipmapping)
     {
-        if (!isPow2(width) || !isPow2(height))
+        if (!npot)
         {
-            return false;
+            if (!isPow2(width) || !isPow2(height))
+            {
+                return false;
+            }
         }
 
         int q = log2(std::max(width, height));
 
         for (int level = 1; level <= q; level++)
         {
             if (mImageArray[level].format != mImageArray[0].format)
             {
@@ -1782,19 +1792,22 @@ void Texture2D::convertToRenderTarget()
 
     mTexture = texture;
     mDirtyImage = true;
     mIsRenderable = true;
 }
 
 void Texture2D::generateMipmaps()
 {
-    if (!isPow2(mImageArray[0].width) || !isPow2(mImageArray[0].height))
+    if (!getContext()->supportsNonPower2Texture())
     {
-        return error(GL_INVALID_OPERATION);
+        if (!isPow2(mImageArray[0].width) || !isPow2(mImageArray[0].height))
+        {
+            return error(GL_INVALID_OPERATION);
+        }
     }
 
     // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
     unsigned int q = log2(std::max(mImageArray[0].width, mImageArray[0].height));
     for (unsigned int i = 1; i <= q; i++)
     {
         if (mImageArray[i].surface != NULL)
         {
@@ -2064,21 +2077,34 @@ bool TextureCubeMap::isComplete() const
         (getInternalFormat() == GL_HALF_FLOAT_OES && !getContext()->supportsHalfFloatLinearFilter()))
     {
         if (mMagFilter != GL_NEAREST || (mMinFilter != GL_NEAREST && mMinFilter != GL_NEAREST_MIPMAP_NEAREST))
         {
             return false;
         }
     }
 
+    bool npot = getContext()->supportsNonPower2Texture();
+
+    if (!npot)
+    {
+        if ((getWrapS() != GL_CLAMP_TO_EDGE || getWrapT() != GL_CLAMP_TO_EDGE) && !isPow2(size))
+        {
+            return false;
+        }
+    }
+
     if (mipmapping)
     {
-        if (!isPow2(size) && (getWrapS() != GL_CLAMP_TO_EDGE || getWrapT() != GL_CLAMP_TO_EDGE))
+        if (!npot)
         {
-            return false;
+            if (!isPow2(size))
+            {
+                return false;
+            }
         }
 
         int q = log2(size);
 
         for (int face = 0; face < 6; face++)
         {
             for (int level = 1; level <= q; level++)
             {
@@ -2441,21 +2467,29 @@ bool TextureCubeMap::isCubeComplete() co
         }
     }
 
     return true;
 }
 
 void TextureCubeMap::generateMipmaps()
 {
-    if (!isPow2(mImageArray[0][0].width) || !isCubeComplete())
+    if (!isCubeComplete())
     {
         return error(GL_INVALID_OPERATION);
     }
 
+    if (!getContext()->supportsNonPower2Texture())
+    {
+        if (!isPow2(mImageArray[0][0].width))
+        {
+            return error(GL_INVALID_OPERATION);
+        }
+    }
+
     // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
     unsigned int q = log2(mImageArray[0][0].width);
     for (unsigned int f = 0; f < 6; f++)
     {
         for (unsigned int i = 1; i <= q; i++)
         {
             if (mImageArray[f][i].surface != NULL)
             {
--- a/gfx/angle/src/libGLESv2/libGLESv2.cpp
+++ b/gfx/angle/src/libGLESv2/libGLESv2.cpp
@@ -23,16 +23,41 @@
 #include "libGLESv2/Context.h"
 #include "libGLESv2/Fence.h"
 #include "libGLESv2/Framebuffer.h"
 #include "libGLESv2/Program.h"
 #include "libGLESv2/Renderbuffer.h"
 #include "libGLESv2/Shader.h"
 #include "libGLESv2/Texture.h"
 
+bool validImageSize(GLint level, GLsizei width, GLsizei height)
+{
+    if (level < 0 || width < 0 || height < 0)
+    {
+        return false;
+    }
+
+    if (gl::getContext() && gl::getContext()->supportsNonPower2Texture())
+    {
+        return true;
+    }
+
+    if (level == 0)
+    {
+        return true;
+    }
+
+    if (gl::isPow2(width) && gl::isPow2(height))
+    {
+        return true;
+    }
+
+    return false;
+}
+
 extern "C"
 {
 
 void __stdcall glActiveTexture(GLenum texture)
 {
     EVENT("(GLenum texture = 0x%X)", texture);
 
     try
@@ -733,22 +758,17 @@ void __stdcall glCompressedTexImage2D(GL
                                       GLint border, GLsizei imageSize, const GLvoid* data)
 {
     EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " 
           "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
           target, level, internalformat, width, height, border, imageSize, data);
 
     try
     {
-        if (level < 0)
-        {
-            return error(GL_INVALID_VALUE);
-        }
-
-        if (width < 0 || height < 0 || (level > 0 && !gl::isPow2(width)) || (level > 0 && !gl::isPow2(height)) || border != 0 || imageSize < 0)
+        if (!validImageSize(level, width, height) || border != 0 || imageSize < 0)
         {
             return error(GL_INVALID_VALUE);
         }
 
         switch (internalformat)
         {
           case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
           case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
@@ -863,23 +883,17 @@ void __stdcall glCompressedTexSubImage2D
 
     try
     {
         if (!gl::IsTextureTarget(target))
         {
             return error(GL_INVALID_ENUM);
         }
 
-        if (level < 0)
-        {
-            return error(GL_INVALID_VALUE);
-        }
-
-        if (xoffset < 0 || yoffset < 0 || width < 0 || height < 0 || 
-            (level > 0 && !gl::isPow2(width)) || (level > 0 && !gl::isPow2(height)) || imageSize < 0)
+        if (xoffset < 0 || yoffset < 0 || !validImageSize(level, width, height) || imageSize < 0)
         {
             return error(GL_INVALID_VALUE);
         }
 
         switch (format)
         {
           case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
           case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
@@ -977,22 +991,17 @@ void __stdcall glCompressedTexSubImage2D
 void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
 {
     EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
           "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
           target, level, internalformat, x, y, width, height, border);
 
     try
     {
-        if (level < 0 || width < 0 || height < 0)
-        {
-            return error(GL_INVALID_VALUE);
-        }
-
-        if (level > 0 && (!gl::isPow2(width) || !gl::isPow2(height)))
+        if (!validImageSize(level, width, height))
         {
             return error(GL_INVALID_VALUE);
         }
 
         if (border != 0)
         {
             return error(GL_INVALID_VALUE);
         }
@@ -4392,22 +4401,17 @@ void __stdcall glTexImage2D(GLenum targe
                             GLint border, GLenum format, GLenum type, const GLvoid* pixels)
 {
     EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
           "GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels =  0x%0.8p)",
           target, level, internalformat, width, height, border, format, type, pixels);
 
     try
     {
-        if (level < 0 || width < 0 || height < 0)
-        {
-            return error(GL_INVALID_VALUE);
-        }
-
-        if (level > 0 && (!gl::isPow2(width) || !gl::isPow2(height)))
+        if (!validImageSize(level, width, height))
         {
             return error(GL_INVALID_VALUE);
         }
 
         if (internalformat != format)
         {
             return error(GL_INVALID_OPERATION);
         }
--- a/mobile/chrome/content/Util.js
+++ b/mobile/chrome/content/Util.js
@@ -157,17 +157,17 @@ let Util = {
   },
 
   isParentProcess: function isInParentProcess() {
     let appInfo = Cc["@mozilla.org/xre/app-info;1"];
     return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
   },
 
   isTablet: function isTablet() {
-    let dpi = this.displayDPI;
+    let dpi = Util.getWindowUtils(window).displayDPI;
     if (dpi <= 96)
       return (window.innerWidth > 1024);
 
     // See the tablet_panel_minwidth from mobile/themes/core/defines.inc
     let tablet_panel_minwidth = 124;
     let dpmm = 25.4 * window.innerWidth / dpi;
     return (dpmm >= tablet_panel_minwidth);
   },
@@ -183,22 +183,16 @@ let Util = {
   },
 
   get isKeyboardOpened() {
     let isChromeWindow = this.isParentProcess() && window["ViewableAreaObserver"];
     if (isChromeWindow)
       return ViewableAreaObserver.isKeyboardOpened;
 
     return (sendSyncMessage("Content:IsKeyboardOpened", {}))[0];
-  },
-
-  // because this uses the global window, will only work in the parent process
-  get displayDPI() function() {
-    delete this.displayDPI;
-    return this.displayDPI = this.getWindowUtils(window).displayDPI;
   }
 };
 
 
 /**
  * Helper class to nsITimer that adds a little more pizazz.  Callback can be an
  * object with a notify method or a function.
  */
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -359,17 +359,17 @@ var BrowserUI = {
   _isKeyboardFullscreen: function _isKeyboardFullscreen() {
 #ifdef ANDROID
     if (!Util.isPortrait()) {
       switch (Services.prefs.getIntPref("widget.ime.android.landscape_fullscreen")) {
         case 1:
           return true;
         case -1: {
           let threshold = Services.prefs.getIntPref("widget.ime.android.fullscreen_threshold");
-          let dpi = Util.displayDPI;
+          let dpi = Util.getWindowUtils(window).displayDPI;
           return (window.innerHeight * 100 < threshold * dpi);
         }
       }
     }
 #endif
     return false;
   },
 
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -1107,17 +1107,17 @@ var Browser = {
 
   // The device-pixel-to-CSS-px ratio used to adjust meta viewport values.
   // This is higher on higher-dpi displays, so pages stay about the same physical size.
   getScaleRatio: function getScaleRatio() {
     let prefValue = Services.prefs.getIntPref("browser.viewport.scaleRatio");
     if (prefValue > 0)
       return prefValue / 100;
 
-    let dpi = Utils.displayDPI;
+    let dpi = this.windowUtils.displayDPI;
     if (dpi < 200) // Includes desktop displays, and LDPI and MDPI Android devices
       return 1;
     else if (dpi < 300) // Includes Nokia N900, and HDPI Android devices
       return 1.5;
 
     // For very high-density displays like the iPhone 4, calculate an integer ratio.
     return Math.floor(dpi / 150);
   },
@@ -1804,17 +1804,17 @@ const ContentTouchHandler = {
   },
 
   touchTimeout: null,
   canCancelPan: false,
   clickPrevented: false,
   panningPrevented: false,
 
   updateCanCancel: function(aX, aY) {
-    let dpi = Utils.displayDPI;
+    let dpi = Browser.windowUtils.displayDPI;
 
     const kSafetyX = Services.prefs.getIntPref("dom.w3c_touch_events.safetyX") / 240 * dpi;
     const kSafetyY = Services.prefs.getIntPref("dom.w3c_touch_events.safetyY") / 240 * dpi;
     let browser = getBrowser();
     let bcr = browser.getBoundingClientRect();
     let rect = new Rect(0, 0, window.innerWidth, window.innerHeight);
     rect.restrictTo(Rect.fromRect(bcr));
 
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -63,21 +63,17 @@ const ElementTouchHelper = {
   get weight() {
     delete this.weight;
     return this.weight = { "visited": Services.prefs.getIntPref("browser.ui.touch.weight.visited")
                          };
   },
 
   /* Retrieve the closest element to a point by looking at borders position */
   getClosest: function getClosest(aWindowUtils, aX, aY) {
-    // cached for the child process, since Utils.displayDPI is only available in the parent
-    if (!this.dpiRatio)
-      this.dpiRatio = aWindowUtils.displayDPI / kReferenceDpi;
-
-    let dpiRatio = this.dpiRatio;
+    let dpiRatio = aWindowUtils.displayDPI / kReferenceDpi;
 
     let target = aWindowUtils.elementFromPoint(aX, aY,
                                                true,   /* ignore root scroll frame*/
                                                false); /* don't flush layout */
 
     // return early if the click is just over a clickable element
     if (this._isElementClickable(target))
       return target;
--- a/mobile/chrome/content/input.js
+++ b/mobile/chrome/content/input.js
@@ -113,17 +113,17 @@ function MouseModule() {
 
   this._kinetic = new KineticController(this._dragBy.bind(this),
                                         this._kineticStop.bind(this));
 
   this._singleClickTimeout = new Util.Timeout(this._doSingleClick.bind(this));
   this._mouseOverTimeout = new Util.Timeout(this._doMouseOver.bind(this));
   this._longClickTimeout = new Util.Timeout(this._doLongClick.bind(this));
 
-  this._doubleClickRadius = Util.displayDPI * kDoubleClickRadius;
+  this._doubleClickRadius = Util.getWindowUtils(window).displayDPI * kDoubleClickRadius;
 
   window.addEventListener("mousedown", this, true);
   window.addEventListener("mouseup", this, true);
   window.addEventListener("mousemove", this, true);
   window.addEventListener("contextmenu", this, false);
   window.addEventListener("CancelTouchSequence", this, true);
 }
 
@@ -565,17 +565,17 @@ MouseModule.prototype = {
       + 'length=' + this._downUpEvents.length + ', '
       + '\n\ttargetScroller=' + this._targetScrollInterface + '}';
   }
 };
 
 var ScrollUtils = {
   // threshold in pixels for sensing a tap as opposed to a pan
   get tapRadius() {
-    let dpi = Util.displayDPI;
+    let dpi = Util.getWindowUtils(window).displayDPI;
 
     delete this.tapRadius;
     return this.tapRadius = Services.prefs.getIntPref("ui.dragThresholdX") / 240 * dpi;
   },
 
   /**
    * Walk up (parentward) the DOM tree from elem in search of a scrollable element.
    * Return the element and its scroll interface if one is found, two nulls otherwise.
@@ -681,17 +681,17 @@ var ScrollUtils = {
 };
 
 /**
  * DragData handles processing drags on the screen, handling both
  * locking of movement on one axis, and click detection.
  */
 function DragData() {
   this._domUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
-  this._lockRevertThreshold = Util.displayDPI * kAxisLockRevertThreshold;
+  this._lockRevertThreshold = Util.getWindowUtils(window).displayDPI * kAxisLockRevertThreshold;
   this.reset();
 };
 
 DragData.prototype = {
   reset: function reset() {
     this.dragging = false;
     this.sX = null;
     this.sY = null;
--- a/security/manager/pki/resources/content/editcerts.js
+++ b/security/manager/pki/resources/content/editcerts.js
@@ -143,31 +143,25 @@ function doLoadForSSLCert()
   }
 /*
   if(cacert == null)
   {
      var editButton = document.getElementById('editca-button');
 	 editButton.setAttribute("disabled","true");
   }
 */  
-  var trustssl = document.getElementById("trustSSLCert");
-  var notrustssl = document.getElementById("dontTrustSSLCert");
-  if (certdb.isCertTrusted(cert, nsIX509Cert.SERVER_CERT, 
-                          nsIX509CertDB.TRUSTED_SSL)) {
-    trustssl.radioGroup.selectedItem = trustssl;
-  } else {
-    trustssl.radioGroup.selectedItem = notrustssl;
-  }
+  var sslTrust = document.getElementById("sslTrustGroup");
+  sslTrust.value = certdb.isCertTrusted(cert, nsIX509Cert.SERVER_CERT, 
+                                        nsIX509CertDB.TRUSTED_SSL);
 }
 
 function doSSLOK()
 {
-  var ssl = document.getElementById("trustSSLCert");
-  //var checked = ssl.getAttribute("value");
-  var trustssl = ssl.selected ? nsIX509CertDB.TRUSTED_SSL : 0;
+  var sslTrust = document.getElementById("sslTrustGroup");
+  var trustssl = sslTrust.value ? nsIX509CertDB.TRUSTED_SSL : 0;
   //
   //  Set the cert trust
   //
   certdb.setCertTrust(cert, nsIX509Cert.SERVER_CERT, trustssl);
   return true;
 }
 
 function doLoadForEmailCert()
@@ -204,31 +198,25 @@ function doLoadForEmailCert()
   }
 /*
   if(cacert == null)
   {
      var editButton = document.getElementById('editca-button');
 	 editButton.setAttribute("disabled","true");
   }
 */  
-  var trustemail = document.getElementById("trustEmailCert");
-  var notrustemail = document.getElementById("dontTrustEmailCert");
-  if (certdb.isCertTrusted(cert, nsIX509Cert.EMAIL_CERT, 
-                          nsIX509CertDB.TRUSTED_EMAIL)) {
-    trustemail.radioGroup.selectedItem = trustemail;
-  } else {
-    trustemail.radioGroup.selectedItem = notrustemail;
-  }
+  var sslTrust = document.getElementById("sslTrustGroup");
+  sslTrust.value = certdb.isCertTrusted(cert, nsIX509Cert.EMAIL_CERT, 
+                                        nsIX509CertDB.TRUSTED_EMAIL);
 }
 
 function doEmailOK()
 {
-  var email = document.getElementById("trustEmailCert");
-  //var checked = ssl.getAttribute("value");
-  var trustemail = email.selected ? nsIX509CertDB.TRUSTED_EMAIL : 0;
+  var sslTrust = document.getElementById("sslTrustGroup");
+  var trustemail = sslTrust.value ? nsIX509CertDB.TRUSTED_EMAIL : 0;
   //
   //  Set the cert trust
   //
   certdb.setCertTrust(cert, nsIX509Cert.EMAIL_CERT, trustemail);
   return true;
 }
 
 function editCaTrust()
@@ -254,17 +242,17 @@ function getCaCertForEntityCert(cert)
    var lastSubjectName="";
    while(true)
    {
      if(nextCertInChain == null)
      {
         return null;
      }
      if((nextCertInChain.type == nsIX509Cert.CA_CERT) || 
-                                 (nextCertInChain.subjectName = lastSubjectName))
+        (nextCertInChain.subjectName == lastSubjectName))
      {
         break;
      }
 
      lastSubjectName = nextCertInChain.subjectName;
      nextCertInChain = nextCertInChain.issuer;
    }
 
--- a/security/manager/pki/resources/content/editemailcert.xul
+++ b/security/manager/pki/resources/content/editemailcert.xul
@@ -55,19 +55,17 @@
 
   <description id="certmsg"/>
   <description id="issuer"/>
   <separator/>
   <description id="explanations"/>
   <separator />
   <description>&certmgr.editemailcert.edittrust;</description>
   <radiogroup id="sslTrustGroup">
-    <radio label="&certmgr.editemailcert.dotrust;"
-           id="trustEmailCert"/>
-    <radio label="&certmgr.editemailcert.donttrust;"
-           id="dontTrustEmailCert"/>
+    <radio label="&certmgr.editemailcert.dotrust;" value="true"/>
+    <radio label="&certmgr.editemailcert.donttrust;" value="false"/>
   </radiogroup>
   <hbox>
     <button id="editca-button" label="&certmgr.editca.label;"
             oncommand="editCaTrust();"/> 
   </hbox>
 
 </dialog>
--- a/security/manager/pki/resources/content/editsslcert.xul
+++ b/security/manager/pki/resources/content/editsslcert.xul
@@ -55,19 +55,17 @@
 
   <description id="certmsg"/>
   <description id="issuer"/>
   <separator/>
   <description id="explanations"/>
   <separator />
   <description>&certmgr.editsslcert.edittrust;</description>
   <radiogroup id="sslTrustGroup">
-    <radio label="&certmgr.editsslcert.dotrust;"
-           id="trustSSLCert"/>
-    <radio label="&certmgr.editsslcert.donttrust;"
-           id="dontTrustSSLCert"/>
+    <radio label="&certmgr.editsslcert.dotrust;" value="true"/>
+    <radio label="&certmgr.editsslcert.donttrust;" value="false"/>
   </radiogroup>
   <hbox>
     <button id="editca-button" label="&certmgr.editca.label;"
             oncommand="editCaTrust();"/> 
   </hbox>
 
 </dialog>
--- a/toolkit/xre/glxtest.cpp
+++ b/toolkit/xre/glxtest.cpp
@@ -164,17 +164,21 @@ static void glxtest()
   ///// Get a FBConfig and a visual /////
   int attribs[] = {
     GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
     GLX_X_RENDERABLE, True,
     0
   };
   int numReturned;
   GLXFBConfig *fbConfigs = glXChooseFBConfig(dpy, DefaultScreen(dpy), attribs, &numReturned );
+  if (!fbConfigs)
+    fatal_error("No FBConfigs found");
   XVisualInfo *vInfo = glXGetVisualFromFBConfig(dpy, fbConfigs[0]);
+  if (!vInfo)
+    fatal_error("No visual found for first FBConfig");
 
   ///// Get a Pixmap and a GLXPixmap /////
   Pixmap pixmap = XCreatePixmap(dpy, RootWindow(dpy, vInfo->screen), 4, 4, 32);
   GLXPixmap glxpixmap = glXCreatePixmap(dpy, fbConfigs[0], pixmap, NULL);
 
   ///// Get a GL context and make it current //////
   GLXContext context = glXCreateNewContext(dpy, fbConfigs[0], GLX_RGBA_TYPE, NULL, True);
   glXMakeCurrent(dpy, glxpixmap, context);
@@ -211,32 +215,36 @@ static void glxtest()
   ///// possible.
   glXDestroyContext(dpy, context);
   glXDestroyPixmap(dpy, glxpixmap);
   XFreePixmap(dpy, pixmap);
   XCloseDisplay(dpy);
   dlclose(libgl);
 }
 
-void fire_glxtest_process()
+/** \returns true in the child glxtest process, false in the parent process */
+bool fire_glxtest_process()
 {
   int pfd[2];
   if (pipe(pfd) == -1) {
       perror("pipe");
-      exit(EXIT_FAILURE);
+      return false;
   }
   pid_t pid = fork();
   if (pid < 0) {
       perror("fork");
-      exit(EXIT_FAILURE);
+      close(pfd[0]);
+      close(pfd[1]);
+      return false;
   }
   if (pid == 0) {
       close(pfd[0]);
       write_end_of_the_pipe = pfd[1];
       glxtest();
       close(pfd[1]);
-      exit(EXIT_SUCCESS);
+      return true;
   }
 
   close(pfd[1]);
   mozilla::widget::glxtest_pipe = pfd[0];
   mozilla::widget::glxtest_pid = pid;
+  return false;
 }
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2714,17 +2714,17 @@ static DWORD InitDwriteBG(LPVOID lpdwThr
   return 0;
 }
 #endif
 
 PRTime gXRE_mainTimestamp = 0;
 
 #ifdef MOZ_X11
 #ifndef MOZ_PLATFORM_MAEMO
-void fire_glxtest_process();
+bool fire_glxtest_process();
 #endif
 #endif
 
 int
 XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
 {
   NS_TIME_FUNCTION;
 
@@ -2744,17 +2744,18 @@ XRE_main(int argc, char* argv[], const n
 #endif
 
   // see bug 639842
   // it's very important to fire this process BEFORE we set up error handling.
   // indeed, this process is expected to be crashy, and we don't want the user to see its crashes.
   // That's the whole reason for doing this in a separate process.
 #ifdef MOZ_X11
 #ifndef MOZ_PLATFORM_MAEMO
-  fire_glxtest_process();
+  if (fire_glxtest_process())
+    return 0;
 #endif
 #endif
 
 #ifdef XP_WIN
   // Vista API.  Mozilla is DPI Aware.
   typedef BOOL (*SetProcessDPIAwareFunc)(VOID);
 
   SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc)