diff options
author | WPT Sync Bot <josh+wptsync@joshmatthews.net> | 2019-07-17 10:25:43 +0000 |
---|---|---|
committer | WPT Sync Bot <josh+wptsync@joshmatthews.net> | 2019-07-17 14:50:17 +0000 |
commit | effeb278b65afa7e857bef8af9e79301e7748750 (patch) | |
tree | c0b636e82db51274ed8c8542281d0f20bf7d4597 /tests/wpt/web-platform-tests/std-toast/resources/helpers.js | |
parent | b6cc0f60a987f306a64defff62c2ebc5f1b1c055 (diff) | |
download | servo-effeb278b65afa7e857bef8af9e79301e7748750.tar.gz servo-effeb278b65afa7e857bef8af9e79301e7748750.zip |
Update web-platform-tests to revision 9a4d479ed1347eb9184abc70d628a6da2297657a
Diffstat (limited to 'tests/wpt/web-platform-tests/std-toast/resources/helpers.js')
-rw-r--r-- | tests/wpt/web-platform-tests/std-toast/resources/helpers.js | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/wpt/web-platform-tests/std-toast/resources/helpers.js b/tests/wpt/web-platform-tests/std-toast/resources/helpers.js index 52d740c144a..256f0c88040 100644 --- a/tests/wpt/web-platform-tests/std-toast/resources/helpers.js +++ b/tests/wpt/web-platform-tests/std-toast/resources/helpers.js @@ -2,10 +2,10 @@ import { showToast, StdToastElement } from 'std:elements/toast'; // helper functions to keep tests from bleeding into each other -const runTest = (testFn, name, toast) => { +const runTest = (testFn, name, toast, action) => { try { test(() => { - testFn(toast); + testFn(toast, action); }, name); } finally { toast.remove(); @@ -41,6 +41,17 @@ export const testShowToast = (testFn, name) => { runTest(testFn, name, toast); }; +export const testActionToast = (testFn, name) => { + const toast = new StdToastElement('Message', {}); + const action = document.createElement('button'); + action.setAttribute('slot', 'action'); + action.textContent = 'action'; + toast.appendChild(action); + document.querySelector('main').appendChild(toast); + + runTest(testFn, name, toast, action); +}; + export const assertToastShown = (toast) => { assert_not_equals(window.getComputedStyle(toast).display, 'none'); assert_true(toast.hasAttribute('open')); @@ -59,6 +70,20 @@ export const assertActionButtonOnToast = (action, toast) => { assert_equals(action, toast.querySelector('button')); }; +export const assertComputedStyleMapsEqual = (element1, element2) => { + assert_greater_than(element1.computedStyleMap().size, 0); + for (const [styleProperty, baseStyleValues] of element1.computedStyleMap()) { + const refStyleValues = element2.computedStyleMap().getAll(styleProperty); + assert_equals(baseStyleValues.length, refStyleValues.length, `${styleProperty} length`); + + for (let i = 0; i < baseStyleValues.length; ++i) { + const baseStyleValue = baseStyleValues[i]; + const refStyleValue = refStyleValues[i]; + assert_equals(baseStyleValue.toString(), refStyleValue.toString(), `diff at value ${styleProperty}`); + } + } +} + export class EventCollector { events = []; |