Commit 8e6773c4 authored by Yuzu Saijo's avatar Yuzu Saijo Committed by Commit Bot

[bfcache] Blocklist WebNfc feature

Bug: 1052733
Change-Id: Idaf0090bd0d1fe242c0c618559a6bdee13f03ed7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2059828Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Commit-Queue: Yuzu Saijo <yuzus@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743879}
parent 723c1ccb
...@@ -277,4 +277,44 @@ IN_PROC_BROWSER_TEST_F(ChromeBackForwardCacheBrowserTest, ...@@ -277,4 +277,44 @@ IN_PROC_BROWSER_TEST_F(ChromeBackForwardCacheBrowserTest,
web_contents()->GetController().GoBack(); web_contents()->GetController().GoBack();
EXPECT_TRUE(content::WaitForLoadStop(web_contents())); EXPECT_TRUE(content::WaitForLoadStop(web_contents()));
} }
IN_PROC_BROWSER_TEST_F(ChromeBackForwardCacheBrowserTest,
DoesNotCacheIfWebNfc) {
// HTTPS needed for WebNfc permission.
net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
https_server.AddDefaultHandlers(GetChromeTestDataDir());
https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
ASSERT_TRUE(https_server.Start());
GURL url_a(https_server.GetURL("a.com", "/title1.html"));
GURL url_b(https_server.GetURL("b.com", "/title1.html"));
// 1) Navigate to A.
EXPECT_TRUE(content::NavigateToURL(web_contents(), url_a));
// Use the WebNfc feature on the empty page.
EXPECT_EQ("success", content::EvalJs(current_frame_host(), R"(
const writer = new NDEFWriter();
new Promise(async resolve => {
try {
await writer.write("Hello");
resolve('success');
} catch (error) {
resolve(error.message);
}
});
)"));
content::RenderFrameDeletedObserver deleted(current_frame_host());
// 2) Navigate away.
EXPECT_TRUE(content::NavigateToURL(web_contents(), url_b));
// The page uses WebShare so it should be deleted.
deleted.WaitUntilDeleted();
// 3) Go back.
web_contents()->GetController().GoBack();
EXPECT_TRUE(content::WaitForLoadStop(web_contents()));
}
#endif #endif
...@@ -83,6 +83,8 @@ const char* FeatureToString(WebSchedulerTrackedFeature feature) { ...@@ -83,6 +83,8 @@ const char* FeatureToString(WebSchedulerTrackedFeature feature) {
return "WebShare"; return "WebShare";
case WebSchedulerTrackedFeature::kRequestedStorageAccessGrant: case WebSchedulerTrackedFeature::kRequestedStorageAccessGrant:
return "requested storage access permission"; return "requested storage access permission";
case WebSchedulerTrackedFeature::kWebNfc:
return "WebNfc";
} }
} }
......
...@@ -80,9 +80,10 @@ enum class WebSchedulerTrackedFeature { ...@@ -80,9 +80,10 @@ enum class WebSchedulerTrackedFeature {
kWebShare = 36, kWebShare = 36,
kRequestedStorageAccessGrant = 37, kRequestedStorageAccessGrant = 37,
kWebNfc = 38,
// NB: This enum is used in a bitmask, so kMaxValue must be less than 64. // NB: This enum is used in a bitmask, so kMaxValue must be less than 64.
kMaxValue = kRequestedStorageAccessGrant kMaxValue = kWebNfc
}; };
static_assert(static_cast<uint32_t>(WebSchedulerTrackedFeature::kMaxValue) < 64, static_assert(static_cast<uint32_t>(WebSchedulerTrackedFeature::kMaxValue) < 64,
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "third_party/blink/renderer/modules/nfc/nfc_utils.h" #include "third_party/blink/renderer/modules/nfc/nfc_utils.h"
#include "third_party/blink/renderer/modules/permissions/permission_utils.h" #include "third_party/blink/renderer/modules/permissions/permission_utils.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/scheduler/public/frame_scheduler.h"
#include "third_party/blink/renderer/platform/scheduler/public/scheduling_policy.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "third_party/blink/renderer/platform/weborigin/kurl.h"
namespace blink { namespace blink {
...@@ -48,6 +50,9 @@ void OnScanRequestCompleted(ScriptPromiseResolver* resolver, ...@@ -48,6 +50,9 @@ void OnScanRequestCompleted(ScriptPromiseResolver* resolver,
// static // static
NDEFReader* NDEFReader::Create(ExecutionContext* context) { NDEFReader* NDEFReader::Create(ExecutionContext* context) {
context->GetScheduler()->RegisterStickyFeature(
SchedulingPolicy::Feature::kWebNfc,
{SchedulingPolicy::RecordMetricsForBackForwardCache()});
return MakeGarbageCollected<NDEFReader>(context); return MakeGarbageCollected<NDEFReader>(context);
} }
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "third_party/blink/renderer/modules/permissions/permission_utils.h" #include "third_party/blink/renderer/modules/permissions/permission_utils.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/scheduler/public/frame_scheduler.h"
#include "third_party/blink/renderer/platform/scheduler/public/scheduling_policy.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h" #include "third_party/blink/renderer/platform/weborigin/security_origin.h"
namespace blink { namespace blink {
...@@ -29,6 +31,9 @@ using mojom::blink::PermissionStatus; ...@@ -29,6 +31,9 @@ using mojom::blink::PermissionStatus;
// static // static
NDEFWriter* NDEFWriter::Create(ExecutionContext* context) { NDEFWriter* NDEFWriter::Create(ExecutionContext* context) {
context->GetScheduler()->RegisterStickyFeature(
blink::SchedulingPolicy::Feature::kWebNfc,
{blink::SchedulingPolicy::RecordMetricsForBackForwardCache()});
return MakeGarbageCollected<NDEFWriter>(context); return MakeGarbageCollected<NDEFWriter>(context);
} }
......
...@@ -48,6 +48,7 @@ bool SchedulingPolicy::IsFeatureSticky(SchedulingPolicy::Feature feature) { ...@@ -48,6 +48,7 @@ bool SchedulingPolicy::IsFeatureSticky(SchedulingPolicy::Feature feature) {
case Feature::kWebLocks: case Feature::kWebLocks:
case Feature::kWakeLock: case Feature::kWakeLock:
case Feature::kRequestedStorageAccessGrant: case Feature::kRequestedStorageAccessGrant:
case Feature::kWebNfc:
return true; return true;
} }
} }
......
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