policy_ImagesAllowedForUrls and policy_ImagesBlockedForUrls tests fail on some web sites. |
|||||
Issue description
There are many pages in the wild that Chrome will display a placeholder image that has the same width as the original image when display of the image is blocked by policy.
The proposed solution is to use the .naturalWidth of the image, not the .width (or .clientWidth), to determine whether Chrome is displaying the image on the page. As stated by Fei Ling:
To test whether an image is blocked, those tests use:
image_is_blocked = tab.EvaluateJavaScript(
"document.getElementById('kittens_id').width") == 0
It turns out this is not 100% reliable. Sometimes it works, but other times, a blocked image still takes up an equivalent amount of space, and this test fails.
The fix is to use the naturalWidth property, which is 0 when the image is blocked:
image_is_blocked = tab.EvaluateJavaScript(
"document.getElementById('kittens_id').naturalWidth") == 0
Note: Bug 604437 fixed an issue where Chrome would sometimes display a non-zero width thumbnail placeholder image when the image was blocked by policy. This fix worked for all the pages tested at that time, since the thumbnail was always much smaller width than the width of the original image.
,
Aug 21 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/third_party/autotest/+/e928f72362ca9cb8b936491044c542b173325289 commit e928f72362ca9cb8b936491044c542b173325289 Author: Scott Cunningham <scunningham@chromium.org> Date: Thu Aug 18 22:02:06 2016 Replace .width with .naturalWidth in image-blocked test. Use the .naturalWidth of the image, not the .width (or .clientWidth), to determine whether Chrome is displaying the image on the page. Currently, policy_ImagesAllowedForUrls & policy_ImagesBlockedForUrls tests use the following to determine whether Chrome is displaying the image on the page: image_is_blocked = tab.EvaluateJavaScript( "document.getElementById('kittens_id').width") < self.MINIMUM_IMAGE_WIDTH It turns out this is not 100% reliable. Sometimes it works, but other times, a blocked image still takes up an equivalent amount of space, and this test fails. The fix is to use the naturalWidth property, which is 0 when the image is blocked: image_is_blocked = tab.EvaluateJavaScript( "document.getElementById('kittens_id').naturalWidth") < self.MINIMUM_IMAGE_WIDTH BUG= chromium:639047 TEST=Run test_that <IP> policy_ImagesAllowedForUrls and policy_ImagesBlockedForUrls. Change-Id: I9e7410b12300a02a8f1b5ecf0cd4ef8d4e36434b Reviewed-on: https://chromium-review.googlesource.com/373159 Commit-Ready: Scott Cunningham <scunningham@chromium.org> Tested-by: Scott Cunningham <scunningham@chromium.org> Reviewed-by: Scott Cunningham <scunningham@chromium.org> Reviewed-by: danny chan <dchan@chromium.org> [modify] https://crrev.com/e928f72362ca9cb8b936491044c542b173325289/client/site_tests/policy_ImagesBlockedForUrls/policy_ImagesBlockedForUrls.py [modify] https://crrev.com/e928f72362ca9cb8b936491044c542b173325289/client/site_tests/policy_ImagesAllowedForUrls/control [modify] https://crrev.com/e928f72362ca9cb8b936491044c542b173325289/client/site_tests/policy_ImagesAllowedForUrls/policy_ImagesAllowedForUrls.py [modify] https://crrev.com/e928f72362ca9cb8b936491044c542b173325289/client/site_tests/policy_ImagesBlockedForUrls/control
,
Sep 6 2016
,
Oct 7 2016
,
Nov 14 2016
Tests passing.
,
Mar 3 2017
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by scunning...@chromium.org
, Aug 19 2016Status: Started (was: Assigned)