Commit a08aa5a7 authored by dpapad's avatar dpapad Committed by Commit Bot

WebUI: Remove defunct PolymerTest.testIronIcons method

This method is using /deep/ which only worked in Shadow DOM v0. WebUI has
been using SDv1 since M72, and this test is silently doing nothing (does not
find any iron-icons to assert on).

Moreover, running additional checks after every test is a questionable
pattern.
 - The state of the DOM is not necessarily valid/useful at the end
   of a unit test (see workaround removed in site_details_permission_test.js).
 - Such checks often confuse developers by throwing an error only if another
   error has happened earlier (which affects the DOM state).
 - Given that these tests are silently injected by the PolymerTest base class
   developers often are not aware that these checks are even happening.

Overall, I think these speculative tests are not worth their maintenance burden.

Bug: 885401
Change-Id: I2574d690dc5596513bc089efd1738805ccd0404d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1863673Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707248}
parent 626d4174
...@@ -108,44 +108,6 @@ PolymerTest.prototype = { ...@@ -108,44 +108,6 @@ PolymerTest.prototype = {
}); });
} }
}, },
/** @override */
tearDown: function() {
// Note: We do this in tearDown() so that we have a chance to stamp all the
// dom-if templates, add elements through interaction, etc.
PolymerTest.testIronIcons(document.body);
testing.Test.prototype.tearDown.call(this);
}
};
/**
* Tests that any iron-icon child of an HTML element has a corresponding
* non-empty svg element.
* @param {!HTMLElement} e The element to check the iron icons in.
*/
PolymerTest.testIronIcons = function(e) {
e.querySelectorAll('* /deep/ iron-icon').forEach(function(icon) {
// Early return if the src is set instead of the icon, since the tests
// below will not work correctly in this case.
if (icon.src && !icon.icon) {
return;
}
// If the icon isn't set (or is set to ''), then don't test this. Having no
// set icon is valid for cases when we don't want to display anything.
if (!icon.icon) {
var rect = icon.getBoundingClientRect();
expectFalse(
rect.width * rect.height > 0,
'iron-icon with undefined "icon" is visible in the DOM.');
return;
}
var svg = icon.$$('svg');
expectTrue(
!!svg && svg.innerHTML != '',
'icon "' + icon.icon + '" is not present');
});
}; };
/** /**
......
...@@ -34,11 +34,6 @@ suite('SiteDetailsPermission', function() { ...@@ -34,11 +34,6 @@ suite('SiteDetailsPermission', function() {
settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy;
PolymerTest.clearBody(); PolymerTest.clearBody();
testElement = document.createElement('site-details-permission'); testElement = document.createElement('site-details-permission');
// Set the camera icon on <site-details-permission> manually to avoid
// failures on undefined icons during teardown in PolymerTest.testIronIcons.
// In practice, this is done from the parent.
testElement.icon = 'cr:videocam';
document.body.appendChild(testElement); document.body.appendChild(testElement);
}); });
......
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