forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle PotentiallyDanglingMarkup() for CSSImageValue
The flag was lost in the KURL -> String -> KURL conversions. Store the flag on CSSImageValue and always re-resolve from the original relative url before fetching when that flag is set. The blocking happens in BaseFetchContext::CanRequestInternal(). Bug: 1039885 Change-Id: Ia5777739a0ee0bee591163873926d19e0ea014bf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3226142 Reviewed-by: Anders Hartvoll Ruud <[email protected]> Reviewed-by: Mike West <[email protected]> Commit-Queue: Rune Lillesveen <[email protected]> Cr-Commit-Position: refs/heads/main@{#932004}
- Loading branch information
Showing
4 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
third_party/blink/renderer/core/css/css_image_value_test.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "third_party/blink/renderer/core/css/css_image_value.h" | ||
|
||
#include "testing/gtest/include/gtest/gtest.h" | ||
#include "third_party/blink/renderer/core/dom/document.h" | ||
#include "third_party/blink/renderer/core/dom/element.h" | ||
#include "third_party/blink/renderer/core/dom/node_computed_style.h" | ||
#include "third_party/blink/renderer/core/loader/resource/image_resource_content.h" | ||
#include "third_party/blink/renderer/core/style/computed_style.h" | ||
#include "third_party/blink/renderer/core/testing/sim/sim_request.h" | ||
#include "third_party/blink/renderer/core/testing/sim/sim_test.h" | ||
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" | ||
|
||
namespace blink { | ||
|
||
class CSSImageValueTest : public SimTest {}; | ||
|
||
TEST_F(CSSImageValueTest, BlockPotentiallyDanglingMarkup) { | ||
SimRequest main_resource("https://example.com", "text/html"); | ||
|
||
LoadURL("https://example.com"); | ||
|
||
main_resource.Complete(R"HTML( | ||
<!doctype html> | ||
<table id="t1" background="ht | ||
tps://example.com/y<ay?foo"><td>XXX</td></table> | ||
<table id="t2" background="ht | ||
tps://example.com/y<ay?bar#boo"><td>XXX</td></table> | ||
)HTML"); | ||
|
||
test::RunPendingTasks(); | ||
Compositor().BeginFrame(); | ||
|
||
auto* t1 = GetDocument().getElementById("t1"); | ||
ImageResourceContent* content1 = | ||
t1->ComputedStyleRef().BackgroundLayers().GetImage()->CachedImage(); | ||
ASSERT_TRUE(content1); | ||
EXPECT_TRUE(content1->ErrorOccurred()); | ||
|
||
auto* t2 = GetDocument().getElementById("t2"); | ||
ImageResourceContent* content2 = | ||
t2->ComputedStyleRef().BackgroundLayers().GetImage()->CachedImage(); | ||
ASSERT_TRUE(content2); | ||
EXPECT_TRUE(content2->ErrorOccurred()); | ||
} | ||
|
||
} // namespace blink |