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

Issue 643621 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 624697



Sign in to add a comment

internals.isPreloaded() should be true even after document's onload

Project Member Reported by hirosh...@chromium.org, Sep 2 2016

Issue description

internals.isPreloaded() can turn false after document's onload or around, because of ResourceFetcher::clearPreloads().

I think internals.isPreloaded() is expected to be true if the url is preloaded at least once, even after document's onload.

 

Comment 2 by y...@yoav.ws, Sep 2 2016

Cc: y...@yoav.ws japhet@chromium.org csharrison@chromium.org
isPreloaded() relies on ResourceFetcher's m_preloads, which gets cleared (at least partially) by clearPreloads. That makes isPreloaded based tests potentially fragile (as we change policies around clearPreloads, when it should be called and what it should do).

At the same time, we want to minimize the amount of test-only code and state we maintain...
One solution would be to make ResourceFetcher to accumulate a set of Strings that represent preloaded URLs only in layout tests. This adds test-only code but no runtime costs other than a flag check per load. (I haven't figure out how to cleanly control whether ResourceFetcher accumulates URLs or not though)

I expect we have to maintain a set of preloaded URLs, not a set of preloaded Resource, because retaining strong references to preloaded Resources will affect the lifetime of Resource and MemoryCache behavior.

Comment 4 by y...@yoav.ws, Sep 2 2016

That sounds like a reasonable way to avoid the tight coupling of current memcache handling code and isPreloaded functionality. Is there a way to ifdef such test-only code away?
Owner: hirosh...@chromium.org
Status: Started (was: Available)
> Is there a way to ifdef such test-only code away?
I expect No.
Probably putting a small piece of code to ResourceFetcher and disabling it in non-test environment by a runtime flag is reasonable.
Drafting a CL.
Project Member

Comment 6 by bugdroid1@chromium.org, Sep 15 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/7978814bba57818814b7a10aa3366e16c6d33784

commit 7978814bba57818814b7a10aa3366e16c6d33784
Author: hiroshige <hiroshige@chromium.org>
Date: Thu Sep 15 10:05:17 2016

Make internals.isPreloaded() to remain the same before/after clearPreloads()

Previously, internals.isPreloaded() depends on |ResourceFetcher::m_preloads|,
which is cleared by ResourceFetcher::clearPreloads().
This caused internals.isPreloaded() to turn false after around document's
load event.

This CL makes ResourceFetcher to keep a set of preloaded URLs (separately
from |m_preloads|) if a blink::Internals object is created, and use the set
to calculate internals.isPreloaded().

BUG= 643621 

Review-Url: https://codereview.chromium.org/2332333003
Cr-Commit-Position: refs/heads/master@{#418821}

[add] https://crrev.com/7978814bba57818814b7a10aa3366e16c6d33784/third_party/WebKit/LayoutTests/fast/preloader/is-preloaded-after-load-expected.txt
[add] https://crrev.com/7978814bba57818814b7a10aa3366e16c6d33784/third_party/WebKit/LayoutTests/fast/preloader/is-preloaded-after-load.html
[modify] https://crrev.com/7978814bba57818814b7a10aa3366e16c6d33784/third_party/WebKit/LayoutTests/http/tests/linkHeader/link-preload-in-iframe.html
[modify] https://crrev.com/7978814bba57818814b7a10aa3366e16c6d33784/third_party/WebKit/LayoutTests/http/tests/linkHeader/resources/iframe-link-headers.php
[modify] https://crrev.com/7978814bba57818814b7a10aa3366e16c6d33784/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
[modify] https://crrev.com/7978814bba57818814b7a10aa3366e16c6d33784/third_party/WebKit/Source/core/fetch/ResourceFetcher.h
[modify] https://crrev.com/7978814bba57818814b7a10aa3366e16c6d33784/third_party/WebKit/Source/core/testing/Internals.cpp

Status: Fixed (was: Started)

Sign in to add a comment