Skip to content

Commit

Permalink
Switch notifications to use base::Value::Dict
Browse files Browse the repository at this point in the history
Change-Id: Ifb7aaa8570438fc0e03d3051536abb6d6cd0c30a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3631191
Reviewed-by: Peter Kvitek <kvitekp@chromium.org>
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1001219}
  • Loading branch information
caseq authored and Chromium LUCI CQ committed May 9, 2022
1 parent 00423fa commit 04f36e5
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 271 deletions.
32 changes: 7 additions & 25 deletions content/browser/devtools/devtools_issue_storage_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ class DevToolsIssueStorageBrowserTest : public DevToolsProtocolTest {
}

void WaitForDummyIssueNotification() {
std::unique_ptr<base::DictionaryValue> notification =
base::Value::Dict notification =
WaitForNotification("Audits.issueAdded", true);
EXPECT_EQ(*(notification->FindDictPath("issue")->FindStringPath("code")),
EXPECT_EQ(*notification.FindStringByDottedPath("issue.code"),
protocol::Audits::InspectorIssueCodeEnum::CookieIssue);
}
};
Expand All @@ -72,41 +72,23 @@ void ReportDummyIssue(RenderFrameHostImpl* rfh) {

IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest,
DevToolsReceivesBrowserIssues) {
// 1) Navigate to about:blank.
EXPECT_TRUE(NavigateToURL(shell(), GURL("about:blank")));

// 2) Report an empty SameSite cookie issue.
// Report an empty SameSite cookie issue.
ReportDummyIssue(main_frame_host());

// 3) Open DevTools.
Attach();

// 4) Verify we haven't received any Issues yet.
ASSERT_TRUE(notifications_.empty());

// 5) Enable audits domain.
SendCommand("Audits.enable", std::make_unique<base::DictionaryValue>());

// 6) Verify we have received the SameSite issue.
// Verify we have received the SameSite issue.
WaitForDummyIssueNotification();
}

IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest,
DevToolsReceivesBrowserIssuesWhileAttached) {
// 1) Navigate to about:blank.
EXPECT_TRUE(NavigateToURL(shell(), GURL("about:blank")));

// 2) Open DevTools and enable Audits domain.
Attach();
SendCommand("Audits.enable", std::make_unique<base::DictionaryValue>());

// 3) Verify we haven't received any Issues yet.
ASSERT_TRUE(notifications_.empty());

// 4) Report an empty SameSite cookie issue.
// Report an empty SameSite cookie issue.
ReportDummyIssue(main_frame_host());

// 5) Verify we have received the SameSite issue.
// Verify we have received the SameSite issue.
WaitForDummyIssueNotification();
}

Expand Down Expand Up @@ -157,7 +139,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsIssueStorageBrowserTest,
SendCommand("Audits.enable", std::make_unique<base::DictionaryValue>());

// 5) Verify that we haven't received any notifications.
ASSERT_TRUE(notifications_.empty());
ASSERT_FALSE(HasExistingNotification());
}

class DevToolsIssueStorageWithBackForwardCacheBrowserTest
Expand Down
8 changes: 4 additions & 4 deletions content/browser/devtools/devtools_trust_token_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsTrustTokenBrowsertest,
SendCommand("Network.enable", std::make_unique<base::DictionaryValue>());

// Make sure there are no existing DevTools events in the queue.
EXPECT_EQ(notifications_.size(), 0ul);
EXPECT_FALSE(HasExistingNotification());

// 3) Issue another redemption, and verify its served from cache.
EXPECT_EQ("NoModificationAllowedError",
Expand Down Expand Up @@ -145,7 +145,7 @@ IN_PROC_BROWSER_TEST_F(
SendCommand("Network.enable", std::make_unique<base::DictionaryValue>());

// Make sure there are no existing DevTools events in the queue.
EXPECT_EQ(notifications_.size(), 0ul);
EXPECT_FALSE(HasExistingNotification());

// Issuance operations successfully answered locally result in
// NoModificationAllowedError.
Expand Down Expand Up @@ -180,13 +180,13 @@ IN_PROC_BROWSER_TEST_F(
namespace {

bool MatchStatus(const std::string& expected_status,
base::DictionaryValue* params) {
const base::DictionaryValue* params) {
std::string actual_status;
EXPECT_TRUE(params->GetString("status", &actual_status));
return expected_status == actual_status;
}

base::RepeatingCallback<bool(base::DictionaryValue*)> okStatusMatcher =
base::RepeatingCallback<bool(const base::DictionaryValue*)> okStatusMatcher =
base::BindRepeating(
&MatchStatus,
protocol::Network::TrustTokenOperationDone::StatusEnum::Ok);
Expand Down

0 comments on commit 04f36e5

Please sign in to comment.