Commit 67e55c4d authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

Remove Chai dependency from whenAttributeIs() WebUI test util

The Chai dependency prohibits the util from being used in WebUI tests
that are not configured to use Chai, like the PDF Viewer's.

Change the assertion to be part of a condition. The assertion was
already strong and unlikely to fail.

Change-Id: I008a6b6ccb1cd8c83d3ec2dcea3476243e89cb0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495506
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821049}
parent c4d2368f
......@@ -541,7 +541,6 @@ js_library("mock_timer.m") {
js_library("test_util.m") {
sources = [ "$root_gen_dir/chrome/test/data/webui/test_util.m.js" ]
deps = [
":chai_assert",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js/cr:event_target.m",
]
......
......@@ -4,10 +4,12 @@
// clang-format off
// #import {afterNextRender, beforeNextRender, flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// #import {assertEquals} from './chai_assert.js';
// #import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';
// clang-format on
// Do not depend on the Chai Assertion Library in this file. Some consumers of
// the following test utils are not configured to use Chai.
cr.define('test_util', function() {
/**
* Observes an HTML attribute and fires a promise when it matches a given
......@@ -26,8 +28,8 @@ cr.define('test_util', function() {
return isDone() ? Promise.resolve() : new Promise(function(resolve) {
new MutationObserver(function(mutations, observer) {
for (const mutation of mutations) {
assertEquals('attributes', mutation.type);
if (mutation.attributeName === attributeName && isDone()) {
if (mutation.type === 'attributes' &&
mutation.attributeName === attributeName && isDone()) {
observer.disconnect();
resolve();
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment