Reset maxCanvasPixelMemory between tests
https://bugs.webkit.org/show_bug.cgi?id=202941
<rdar://problem/56260865>

Reviewed by Wenson Hsieh.

Source/WebCore:

Reset the maximum canvas memory between tests.

* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):

LayoutTests:

Swap the order of the tests, because a previous test might have
already allocated canvas memory that is sitting around.

* fast/canvas/canvas-too-large-to-draw.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251094 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 3922879..e131a0c 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2019-10-14  Dean Jackson  <dino@apple.com>
+
+        Reset maxCanvasPixelMemory between tests
+        https://bugs.webkit.org/show_bug.cgi?id=202941
+        <rdar://problem/56260865>
+
+        Reviewed by Wenson Hsieh.
+
+        Swap the order of the tests, because a previous test might have
+        already allocated canvas memory that is sitting around.
+
+        * fast/canvas/canvas-too-large-to-draw.html:
+
 2019-10-14  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [Mac] Update fast/text/font-cursive-italic-cjk-2.html for Catalina
diff --git a/LayoutTests/fast/canvas/canvas-too-large-to-draw.html b/LayoutTests/fast/canvas/canvas-too-large-to-draw.html
index 3a7fd20..5956007 100644
--- a/LayoutTests/fast/canvas/canvas-too-large-to-draw.html
+++ b/LayoutTests/fast/canvas/canvas-too-large-to-draw.html
@@ -38,11 +38,11 @@
             ctx.fillRect(0, 0, width, height);
         }
     
-        // This uses up all the available memory.
-        fillCanvas("canvas1", MAX_WIDTH, MAX_HEIGHT);
-
-        // Any new canvas from now on should exceed the memory limit.
+        // This one should always work.
         fillCanvas("canvas2", 10, 10);
+
+        // And this one should exceed the memory limit.
+        fillCanvas("canvas1", MAX_WIDTH + 1, MAX_HEIGHT + 1);
     }
     run();
 </script>
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 117b129..0b7afd0 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,16 @@
+2019-10-14  Dean Jackson  <dino@apple.com>
+
+        Reset maxCanvasPixelMemory between tests
+        https://bugs.webkit.org/show_bug.cgi?id=202941
+        <rdar://problem/56260865>
+
+        Reviewed by Wenson Hsieh.
+
+        Reset the maximum canvas memory between tests.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::resetToConsistentState):
+
 2019-10-14  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [Cocoa] font-family:system-ui on Chinese systems don't get Chinese quote marks
diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp
index 3a9e6c2..8f8c5c7 100644
--- a/Source/WebCore/testing/Internals.cpp
+++ b/Source/WebCore/testing/Internals.cpp
@@ -535,6 +535,8 @@
 #if ENABLE(MEDIA_STREAM)
     RuntimeEnabledFeatures::sharedFeatures().setInterruptAudioOnPageVisibilityChangeEnabled(false);
 #endif
+
+    HTMLCanvasElement::setMaxPixelMemoryForTesting(0); // This means use the default value.
 }
 
 Internals::Internals(Document& document)