blob: ab948494bd790a96d7454c853499b4e97615b99d [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2020 The Chromium Authors
Brandon Maslen6134c852020-05-18 21:45:212// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_NET_STORAGE_TEST_UTILS_H_
6#define CHROME_BROWSER_NET_STORAGE_TEST_UTILS_H_
7
8#include <string>
9
Shuran Huangae8c32822023-01-25 21:01:1010class GURL;
11
Brandon Maslen6134c852020-05-18 21:45:2112namespace content {
Brandon Maslen6134c852020-05-18 21:45:2113class RenderFrameHost;
14} // namespace content
15
Chris Fredricksone90c7a3c2023-03-09 19:40:1816namespace storage::test {
Brandon Maslen6134c852020-05-18 21:45:2117
Chris Fredricksonf39f87b2022-07-11 11:34:0418// Gets the text content of a given frame.
19std::string GetFrameContent(content::RenderFrameHost* frame);
Brandon Maslen6134c852020-05-18 21:45:2120
21// Helpers to set and check various types of storage on a given frame. Typically
22// used on page like //chrome/test/data/browsing_data/site_data.html
Chris Fredrickson61269f52022-08-11 18:27:3523void SetStorageForFrame(content::RenderFrameHost* frame, bool include_cookies);
Asami Doibcbe9af2021-03-24 04:50:5224void SetStorageForWorker(content::RenderFrameHost* frame);
Chris Fredrickson61269f52022-08-11 18:27:3525void ExpectStorageForFrame(content::RenderFrameHost* frame,
26 bool include_cookies,
27 bool expected);
Asami Doibcbe9af2021-03-24 04:50:5228void ExpectStorageForWorker(content::RenderFrameHost* frame, bool expected);
Brandon Maslen6134c852020-05-18 21:45:2129
30// Helpers to set and check various types of cross tab info for a given frame.
31// Typically used on page like //chrome/test/data/browsing_data/site_data.html
32void SetCrossTabInfoForFrame(content::RenderFrameHost* frame);
33void ExpectCrossTabInfoForFrame(content::RenderFrameHost* frame, bool expected);
34
35// Helper to request storage access for a frame using
Chris Fredricksone90c7a3c2023-03-09 19:40:1836// document.requestStorageAccess(). Returns true if the promise resolves *and*
37// if a subsequent call to `document.hasStorageAccess()` resolves and returns
38// true; false otherwise.
39bool RequestAndCheckStorageAccessForFrame(content::RenderFrameHost* frame);
Matt Reichhoff70f539f52022-08-19 21:35:0140// Helper to request storage access with a site override for a frame using
Matt Reichhoffa0a390d2023-03-16 11:50:3041// document.requestStorageAccessFor(origin). Returns true if the promise
Matt Reichhoff70f539f52022-08-19 21:35:0142// resolves; false if it rejects.
Matt Reichhoff