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

Unified Diff: third_party/WebKit/LayoutTests/csspaint/resources/test-runner-invalidation-logging.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
Index: third_party/WebKit/LayoutTests/csspaint/resources/test-runner-invalidation-logging.js
diff --git a/third_party/WebKit/LayoutTests/csspaint/resources/test-runner-invalidation-logging.js b/third_party/WebKit/LayoutTests/csspaint/resources/test-runner-invalidation-logging.js
deleted file mode 100644
index 06110c9f5c339f0e04bfa2d324f598b14a0b79d6..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/csspaint/resources/test-runner-invalidation-logging.js
+++ /dev/null
@@ -1,101 +0,0 @@
-// Test runner for the paint worklet to test invalidation behaviour.
-//
-// Registers an promise_test per test case, which:
-// - Creates an element.
-// - Invalidates the style of that element.
-// - [worklet] Worklet code logs if it got the invalidation.
-// - Asserts that it got the correct paint invalidation.
-//
-// Usage:
-// testRunnerInvalidationLogging('background-image', [
-// { property: 'max-height', value: '100px' },
-// { property: 'color', prevValue: '#00F', value: 'blue', noInvalidation: true },
-// { property: '-webkit-margin-start', invalidationProperty: 'margin-left', prevValue: 'calc(50px + 50px)', value: '100px', noInvalidation: true }
-// ]);
-
-function testRunnerInvalidationLogging(imageType, tests) {
- const keys = tests.map(function(obj) { return obj.property; });
- const workletCode = 'const properties = ' + JSON.stringify(keys) + ';\n' + `
- for (let i = 0; i < properties.length; i++) {
- registerPaint('paint-' + i, class {
- static get inputProperties() { return [properties[i]]; }
- constructor() { this.hasPainted= false; }
- paint(ctx, geom) {
- ctx.fillStyle = this.hasPainted ? 'green' : 'blue';
- ctx.fillRect(0, 0, geom.width, geom.height);
- if (this.hasPainted) {
- console.log('Successful invalidation for: ' + properties[i]);
- }
- this.hasPainted = true;
- }
- });
- }
- `;
-
- paintWorklet.addModule(URL.createObjectURL(new Blob([workletCode], {type: 'text/javascript'}))).then(function() {
- for (let i = 0; i < tests.length; i++) {
- tests[i].paintName = 'paint-' + i;
- registerTest(imageType, tests[i]);
- }
- });
-}
-
-function registerTest(imageType, test) {
- const testName = test.property + ': ' + (test.prevValue || '[inline not set]') + ' => ' + (test.invalidationProperty || test.property) + ': ' + (test.value || '[inline not set]');
-
- // We use a promise_test instead of a async_test as they run sequentially.
- promise_test(function() {
- return new Promise(function(resolve) {
-
- const msg = ['\n\nTest case:', testName];
- if (test.noInvalidation) {
- msg.push('The worklet console should log nothing');
- } else {
- msg.push('The worklet console should log: \'Successful invalidation for: ' + test.property + '\'');
- }
- console.log(msg.join('\n'));
-
- // Create the test div.
- const el = document.createElement('div');
- if (test.prevValue) el.style.setProperty(test.property, test.prevValue);
- el.style[imageType] = 'paint(' + test.paintName + ')';
- document.body.appendChild(el);
-
- runAfterLayoutAndPaint(function() {
- if (window.internals)
- internals.startTrackingRepaints(document);
-
- // Keep the BCR for the paint invalidation assertion, and invalidate paint.
- const rect = el.getBoundingClientRect();
- if (test.invalidationProperty) {
- el.style.setProperty(test.invalidationProperty, test.value);
- } else {
- el.style.setProperty(test.property, test.value);
- }
-
- runAfterLayoutAndPaint(function() {
- // Check that the we got the correct paint invalidation.
- if (window.internals) {
- const layers = JSON.parse(internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS));
- const paintInvalidations = layers['layers'][0]['paintInvalidations'];
- assert_equals(!paintInvalidations, !!test.noInvalidation);
- if (paintInvalidations) {
- assert_equals(paintInvalidations.length, 1, 'There should be only one paint invalidation.');
- assert_array_equals(
- paintInvalidations[0]['rect'],
- [rect.left, rect.top, rect.width, rect.height],
- 'The paint invalidation should cover the entire element.');
- }
- internals.stopTrackingRepaints(document);
- }
-
- // Cleanup.
- document.body.removeChild(el);
- resolve();
- });
- });
-
- });
-
- }, testName);
-}

Powered by Google App Engine
This is Rietveld 408576698