New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 639047 link

Starred by 1 user

Issue metadata

Status: Verified
Owner: ----
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug



Sign in to add a comment

policy_ImagesAllowedForUrls and policy_ImagesBlockedForUrls tests fail on some web sites.

Project Member Reported by scunning...@chromium.org, Aug 18 2016

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.
 
Cc: dchan@chromium.org
Status: Started (was: Assigned)
CL: https://chromium-review.googlesource.com/#/c/373159/
Project Member

Comment 2 by bugdroid1@chromium.org, 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

Status: Fixed (was: Started)

Comment 4 by dchan@chromium.org, Oct 7 2016

Labels: VerifyIn-55
Cc: krishna...@chromium.org
Status: Verified (was: Fixed)
Tests passing.
Owner: ----

Sign in to add a comment