Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/resources/run-after-layout-and-paint.js

Issue 2868003002: CSSPaint: Move layout tests in csspaint/ to http/tests/csspaint/ (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/csspaint/valid-image-before-load-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/resources/run-after-layout-and-paint.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/resources/run-after-layout-and-paint.js b/third_party/WebKit/LayoutTests/http/tests/resources/run-after-layout-and-paint.js
new file mode 100644
index 0000000000000000000000000000000000000000..e3173417aef5084f6c544b271507c86295c9b011
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/resources/run-after-layout-and-paint.js
@@ -0,0 +1,43 @@
+// Run a callback after layout and paint of all pending document changes.
+//
+// It has two modes:
+// - traditional mode, for existing tests, and tests needing customized notifyDone timing:
+// Usage:
+// if (window.testRunner)
+// testRunner.waitUntilDone();
+// runAfterLayoutAndPaint(function() {
+// ... // some code which modifies style/layout
+// if (window.testRunner)
+// testRunner.notifyDone();
+// // Or to ensure the next paint is executed before the test finishes:
+// // if (window.testRunner)
+// // runAfterAfterLayoutAndPaint(function() { testRunner.notifyDone() });
+// // Or notifyDone any time later if needed.
+// });
+//
+// - autoNotifyDone mode, for new tests which just need to change style/layout and finish:
+// Usage:
+// runAfterLayoutAndPaint(function() {
+// ... // some code which modifies style/layout
+// }, true);
+
+if (window.internals)
+ internals.runtimeFlags.paintUnderInvalidationCheckingEnabled = true;
+
+function runAfterLayoutAndPaint(callback, autoNotifyDone) {
+ if (!window.testRunner) {
+ // For manual test. Delay 500ms to allow us to see the visual change
+ // caused by the callback.
+ setTimeout(callback, 500);
+ return;
+ }
+
+ if (autoNotifyDone)
+ testRunner.waitUntilDone();
+
+ testRunner.layoutAndPaintAsyncThen(function() {
+ callback();
+ if (autoNotifyDone)
+ testRunner.notifyDone();
+ });
+}
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/csspaint/valid-image-before-load-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698