|
|
Chromium Code Reviews|
Created:
3 years, 10 months ago by dpapad Modified:
3 years, 10 months ago CC:
arv+watch_chromium.org, chromium-reviews, dbeam+watch-settings_chromium.org, Dan Beam, michaelpg+watch-md-settings_chromium.org, michaelpg+watch-md-ui_chromium.org, stevenjb+watch-md-settings_chromium.org Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionMD Settings: Fix timezone autodetect policy indicator.
The cr-policy-pref-indicator was referring to a non-existing property, but the
corresponding tests did not catch the bug, because they were asserting on a
condition that was not sufficient. Moreover, the tests did not fire a
'time-zone-auto-detect-policy' WebUI event which is necessary to initialize the
fakeTimeZonePolicyPref_ property, which controls the pref indicator.
BUG=689302
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation
Review-Url: https://codereview.chromium.org/2683613003
Cr-Commit-Position: refs/heads/master@{#449524}
Committed: https://chromium.googlesource.com/chromium/src/+/74b7a0510c3aca53680a8d65fdc65d384c1d04b6
Patch Set 1 #Patch Set 2 : Nit. #
Total comments: 12
Patch Set 3 : Use getter instead of private state. #
Messages
Total messages: 35 (19 generated)
Description was changed from ========== MD Settings: Fix timezone autodetect policy indicator. The cr-policy-pref-indicator was referring to a non-existing property, but the corresponding tests did not catch the bug, because they were asserting on a condition that was not sufficient. BUG=689302 ========== to ========== MD Settings: Fix timezone autodetect policy indicator. The cr-policy-pref-indicator was referring to a non-existing property, but the corresponding tests did not catch the bug, because they were asserting on a condition that was not sufficient. BUG=689302 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ==========
The CQ bit was checked by dpapad@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #2 (id:20001) has been deleted
The CQ bit was checked by dpapad@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== MD Settings: Fix timezone autodetect policy indicator. The cr-policy-pref-indicator was referring to a non-existing property, but the corresponding tests did not catch the bug, because they were asserting on a condition that was not sufficient. BUG=689302 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ========== to ========== MD Settings: Fix timezone autodetect policy indicator. The cr-policy-pref-indicator was referring to a non-existing property, but the corresponding tests did not catch the bug, because they were asserting on a condition that was not sufficient. Moreover, the tests did not fire a 'time-zone-auto-detect-policy' WebUI event which is necessary to initialize the fakeTimeZonePolicyPref_ property, which controls the pref indicator. BUG=689302 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ==========
dpapad@chromium.org changed reviewers: + michaelpg@chromium.org
https://codereview.chromium.org/2683613003/diff/40001/chrome/browser/resource... File chrome/browser/resources/settings/date_time_page/date_time_page.html (right): https://codereview.chromium.org/2683613003/diff/40001/chrome/browser/resource... chrome/browser/resources/settings/date_time_page/date_time_page.html:35: <cr-policy-pref-indicator pref="[[fakeTimeZonePolicyPref_]]"> We should probably replace this usage of cr-policy-pref-indicator+paper-togggle-button with a settings-toggle-button, see https://cs.chromium.org/chromium/src/chrome/browser/resources/settings/contro.... Either way, I'll leave that for a future cleanup, since my priority is to fix the tests and unblock Vulcanization. We could also use a browser proxy from date_time_page.js instead of directly calling chrome.send, but I'll leave that for a future cleanup as well.
On 2017/02/07 at 18:30:26, dpapad wrote: > https://codereview.chromium.org/2683613003/diff/40001/chrome/browser/resource... > File chrome/browser/resources/settings/date_time_page/date_time_page.html (right): > > https://codereview.chromium.org/2683613003/diff/40001/chrome/browser/resource... > chrome/browser/resources/settings/date_time_page/date_time_page.html:35: <cr-policy-pref-indicator pref="[[fakeTimeZonePolicyPref_]]"> > We should probably replace this usage of cr-policy-pref-indicator+paper-togggle-button with a settings-toggle-button, see https://cs.chromium.org/chromium/src/chrome/browser/resources/settings/contro.... Either way, I'll leave that for a future cleanup, since my priority is to fix the tests and unblock Vulcanization. > > We could also use a browser proxy from date_time_page.js instead of directly calling chrome.send, but I'll leave that for a future cleanup as well. After screenshots: http://imgur.com/a/fYW2B.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... File chrome/test/data/webui/settings/date_time_page_tests.js (left): https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... chrome/test/data/webui/settings/date_time_page_tests.js:124: assertGT(indicator.clientHeight, 0); would indicator.$$('iron-icon').clientHeight be sufficient? I thought checking for clientHeight was a more robust way to detect whether or not an element is hidden, because there are a bunch of ways to do so (display: none, hidden = true, etc.) https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... File chrome/test/data/webui/settings/date_time_page_tests.js (right): https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... chrome/test/data/webui/settings/date_time_page_tests.js:124: assertNotEquals('none', indicator.style.display); generally we should check getComputedStyle, because e.g. <cr-policy-pref-indicator hidden> would result in a computed display of none, but the element's "display" style property would still be empty.
https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... File chrome/test/data/webui/settings/date_time_page_tests.js (left): https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... chrome/test/data/webui/settings/date_time_page_tests.js:124: assertGT(indicator.clientHeight, 0); On 2017/02/08 at 00:07:12, michaelpg wrote: > would indicator.$$('iron-icon').clientHeight be sufficient? > > I thought checking for clientHeight was a more robust way to detect whether or not an element is hidden, because there are a bunch of ways to do so (display: none, hidden = true, etc.) Actually it is not at all robust. Here is why: The [hidden] attribute works in custom Polymer elements, only because some transitive dependency is leaking the following CSS rule html /deep/ [hidden] { display: none !important;} (one of those two https://cs.chromium.org/search/?q=%22html+/deep/+%5Bhidden%5D%22+file:%5Esrc/...). You can verify this from the devtools, see http://imgur.com/a/HnzDM, as well as from the discussion at https://github.com/Polymer/polymer/issues/3711#issuecomment-226172158. Our test is loading a specific URL that does not depend on those elements, which means that applying the hidden property does really nothing in terms of hiding the iron-icon, and its clientHeight is still 20px (you can also verify this by applying this CL locally, reverting the one line fix in date_time_page.js and use console.log here). https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... File chrome/test/data/webui/settings/date_time_page_tests.js (right): https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... chrome/test/data/webui/settings/date_time_page_tests.js:124: assertNotEquals('none', indicator.style.display); On 2017/02/08 at 00:07:12, michaelpg wrote: > generally we should check getComputedStyle, because e.g. > > <cr-policy-pref-indicator hidden> > > would result in a computed display of none, but the element's "display" style property would still be empty. Tried getComputedStyle() and it throws TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. at value (chrome://resources/polymer/v1_0/web-animations-js/web-animations-next-lite.min.js:16:12769) at verifyPolicy (date_time_page_tests.js:134:32) at Context.<anonymous> (date_time_page_tests.js:157:7) ", source: mocha_adapter.js (48) which is very odd, since |indicator| is a Polymer element. I tried the following to see console.log(indicator instanceof Element); // false console.log(indicator instanceof HTMLElement); // false console.log(indicator.appendChild) // function appendChild() { [native code] } I don't know why this is happening, but I'd rather not block this CL on it.
dbeam@chromium.org changed reviewers: + dbeam@chromium.org
https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... File chrome/test/data/webui/settings/date_time_page_tests.js (right): https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... chrome/test/data/webui/settings/date_time_page_tests.js:125: assertTrue(!!indicator.$$('iron-icon')); why are we looking into indicator itself?
lgtm https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... File chrome/test/data/webui/settings/date_time_page_tests.js (left): https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... chrome/test/data/webui/settings/date_time_page_tests.js:124: assertGT(indicator.clientHeight, 0); On 2017/02/08 01:53:50, dpapad wrote: > On 2017/02/08 at 00:07:12, michaelpg wrote: > > would indicator.$$('iron-icon').clientHeight be sufficient? > > > > I thought checking for clientHeight was a more robust way to detect whether or > not an element is hidden, because there are a bunch of ways to do so (display: > none, hidden = true, etc.) > > Actually it is not at all robust. Here is why: > > The [hidden] attribute works in custom Polymer elements, only because some > transitive dependency is leaking the following CSS rule > html /deep/ [hidden] { display: none !important;} > (one of those two > https://cs.chromium.org/search/?q=%22html+/deep/+%5Bhidden%5D%22+file:%5Esrc/...). > > You can verify this from the devtools, see http://imgur.com/a/HnzDM, as well as > from the discussion at > https://github.com/Polymer/polymer/issues/3711#issuecomment-226172158. > > Our test is loading a specific URL that does not depend on those elements, which > means that applying the hidden property does really nothing in terms of hiding > the iron-icon, and its clientHeight is still 20px (you can also verify this by > applying this CL locally, reverting the one line fix in date_time_page.js and > use console.log here). Jeez. Can't wait to get rid of those iron-flex global hidden attributes. Can you add a TODO to replace these checks with clientHeight-type checks, blocked on 635633 and/or 498405? Thanks. https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... File chrome/test/data/webui/settings/date_time_page_tests.js (right): https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... chrome/test/data/webui/settings/date_time_page_tests.js:124: assertNotEquals('none', indicator.style.display); On 2017/02/08 01:53:50, dpapad wrote: > On 2017/02/08 at 00:07:12, michaelpg wrote: > > generally we should check getComputedStyle, because e.g. > > > > <cr-policy-pref-indicator hidden> > > > > would result in a computed display of none, but the element's "display" style > property would still be empty. > > Tried getComputedStyle() and it throws > > TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not > of type 'Element'. > at value > (chrome://resources/polymer/v1_0/web-animations-js/web-animations-next-lite.min.js:16:12769) > at verifyPolicy (date_time_page_tests.js:134:32) > at Context.<anonymous> (date_time_page_tests.js:157:7) > ", source: mocha_adapter.js (48) > > which is very odd, since |indicator| is a Polymer element. I tried the following > to see > console.log(indicator instanceof Element); // false > console.log(indicator instanceof HTMLElement); // false > console.log(indicator.appendChild) // function appendChild() { [native code] } > > I don't know why this is happening, but I'd rather not block this CL on it. Yeah I'm at a loss there.
https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... File chrome/test/data/webui/settings/date_time_page_tests.js (right): https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... chrome/test/data/webui/settings/date_time_page_tests.js:125: assertTrue(!!indicator.$$('iron-icon')); On 2017/02/08 at 02:14:23, Dan Beam wrote: > why are we looking into indicator itself? In lack of a better way to verify if the on/off state of the policy pref had any effect on the DOM. cr-policy-pref-indicator does not expose that info (for example via an attribute) AND does not have unit tests. Summarizing offline discussions we have 3 options 1) Update cr-policy-pref-indicator to expose and |active| HTML attribute. Assert on that. Add unit tests for cr-policy-pref-indicator. 2) Migrate to settings-toggle (if possible), which already exposes a |checked| attribute (and has unit tests). Assert on the |checked| attribute here, avoiding querying any private state. 3) Let this CL through, since it fixes a bug, improves broken tests, and allows me to stay focused on the vulcanized stuff, instead of going of course.
Addressing dbeam's testing concerns. PTAL. Thanks. https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... File chrome/test/data/webui/settings/date_time_page_tests.js (right): https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... chrome/test/data/webui/settings/date_time_page_tests.js:125: assertTrue(!!indicator.$$('iron-icon')); > Summarizing offline discussions we have 3 options > 1) Update cr-policy-pref-indicator to expose and |active| HTML attribute. Assert on that. Add unit tests for cr-policy-pref-indicator. > 2) Migrate to settings-toggle (if possible), which already exposes a |checked| attribute (and has unit tests). Assert on the |checked| attribute here, avoiding querying any private state. > 3) Let this CL through, since it fixes a bug, improves broken tests, and allows me to stay focused on the vulcanized stuff, instead of going of course. @dbeam PTAL: I added an isActive() method on cr-policy-pref-indicator. I also added a "restamp" on the surrounding dom-if so that we don't need to check for display or the presence of the element. This simplifies things a lot, and addresses your concerns of querying private state during tests (no need to deal with iron-icons anymore). FWIW, I also tried exposing an |active| HTML attribute, instead of the isActive() method, but the former was problematic for multiple reasons. - The attribute is unnecessary calculated even if nobody is querying for it. - The attribute is editable from the outside, but the indicator state should only be dictated by the pref. For those reasons the isActive() method seems like the best approach.
lgtm
The CQ bit was checked by dpapad@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from michaelpg@chromium.org Link to the patchset: https://codereview.chromium.org/2683613003/#ps60001 (title: "Use getter instead of private state.")
The CQ bit was unchecked by dpapad@chromium.org
https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... File chrome/test/data/webui/settings/date_time_page_tests.js (left): https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... chrome/test/data/webui/settings/date_time_page_tests.js:124: assertGT(indicator.clientHeight, 0); > Can you add a TODO to replace these checks with clientHeight-type checks, blocked on 635633 and/or 498405? > > Thanks. Michael do you still this TODO is worth it? The code now uses a dedicated cr-policy-pref-indicator#isActive() method, so I don't think we need to revert to checking clientHeight in the future. (We should add unit tests for cr-pref-policy-indicator though.)
On 2017/02/08 at 22:03:40, dpapad wrote: > https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... > File chrome/test/data/webui/settings/date_time_page_tests.js (left): > > https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... > chrome/test/data/webui/settings/date_time_page_tests.js:124: assertGT(indicator.clientHeight, 0); > > Can you add a TODO to replace these checks with clientHeight-type checks, blocked on 635633 and/or 498405? > > > > Thanks. > > Michael do you still this TODO is worth it? The code now uses a dedicated cr-policy-pref-indicator#isActive() method, so I don't think we need to revert to checking clientHeight in the future. (We should add unit tests for cr-pref-policy-indicator though.) Michael, friendly ping about the TODO question above.
slgtm https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... File chrome/test/data/webui/settings/date_time_page_tests.js (left): https://codereview.chromium.org/2683613003/diff/40001/chrome/test/data/webui/... chrome/test/data/webui/settings/date_time_page_tests.js:124: assertGT(indicator.clientHeight, 0); On 2017/02/08 22:03:40, dpapad wrote: > > Can you add a TODO to replace these checks with clientHeight-type checks, > blocked on 635633 and/or 498405? > > > > Thanks. > > Michael do you still this TODO is worth it? The code now uses a dedicated > cr-policy-pref-indicator#isActive() method, so I don't think we need to revert > to checking clientHeight in the future. (We should add unit tests for > cr-pref-policy-indicator though.) SGTM.
The CQ bit was checked by dpapad@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
The CQ bit was checked by dpapad@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 60001, "attempt_start_ts": 1486691097590990,
"parent_rev": "5321deced002ddaf841dec0b1d797f836495e84f", "commit_rev":
"74b7a0510c3aca53680a8d65fdc65d384c1d04b6"}
Message was sent while issue was closed.
Description was changed from ========== MD Settings: Fix timezone autodetect policy indicator. The cr-policy-pref-indicator was referring to a non-existing property, but the corresponding tests did not catch the bug, because they were asserting on a condition that was not sufficient. Moreover, the tests did not fire a 'time-zone-auto-detect-policy' WebUI event which is necessary to initialize the fakeTimeZonePolicyPref_ property, which controls the pref indicator. BUG=689302 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ========== to ========== MD Settings: Fix timezone autodetect policy indicator. The cr-policy-pref-indicator was referring to a non-existing property, but the corresponding tests did not catch the bug, because they were asserting on a condition that was not sufficient. Moreover, the tests did not fire a 'time-zone-auto-detect-policy' WebUI event which is necessary to initialize the fakeTimeZonePolicyPref_ property, which controls the pref indicator. BUG=689302 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation Review-Url: https://codereview.chromium.org/2683613003 Cr-Commit-Position: refs/heads/master@{#449524} Committed: https://chromium.googlesource.com/chromium/src/+/74b7a0510c3aca53680a8d65fdc6... ==========
Message was sent while issue was closed.
Committed patchset #3 (id:60001) as https://chromium.googlesource.com/chromium/src/+/74b7a0510c3aca53680a8d65fdc6... |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
