blob: 3e836b7b7f05dafb17cbb07a99e08f536ff4e64e [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
Brandon Maslen6134c852020-05-18 21:45:2110namespace content {
Brandon Maslen6134c852020-05-18 21:45:2111class RenderFrameHost;
12} // namespace content
13
14namespace storage {
15namespace test {
16
Chris Fredricksonf39f87b2022-07-11 11:34:0417// Gets the text content of a given frame.
18std::string GetFrameContent(content::RenderFrameHost* frame);
Brandon Maslen6134c852020-05-18 21:45:2119
20// Helpers to set and check various types of storage on a given frame. Typically
21// used on page like //chrome/test/data/browsing_data/site_data.html
Chris Fredrickson61269f52022-08-11 18:27:3522void SetStorageForFrame(content::RenderFrameHost* frame, bool include_cookies);
Asami Doibcbe9af2021-03-24 04:50:5223void SetStorageForWorker(content::RenderFrameHost* frame);
Chris Fredrickson61269f52022-08-11 18:27:3524void ExpectStorageForFrame(content::RenderFrameHost* frame,
25 bool include_cookies,
26 bool expected);
Asami Doibcbe9af2021-03-24 04:50:5227void ExpectStorageForWorker(content::RenderFrameHost* frame, bool expected);
Brandon Maslen6134c852020-05-18 21:45:2128
29// Helpers to set and check various types of cross tab info for a given frame.
30// Typically used on page like //chrome/test/data/browsing_data/site_data.html
31void SetCrossTabInfoForFrame(content::RenderFrameHost* frame);
32void ExpectCrossTabInfoForFrame(content::RenderFrameHost* frame, bool expected);
33
34// Helper to request storage access for a frame using
Chris Fredricksonf39f87b2022-07-11 11:34:0435// document.requestStorageAccess(). Returns true if the promise resolves; false
36// if it rejects.
37bool RequestStorageAccessForFrame(content::RenderFrameHost* frame);
Matt Reichhoff70f539f52022-08-19 21:35:0138// Helper to request storage access with a site override for a frame using
39// document.requestStorageAccessForSite(site). Returns true if the promise
40// resolves; false if it rejects.
41bool RequestStorageAccessForSite(content::RenderFrameHost* frame,
42 const std::string& site);
Chris Fredricksonf39f87b2022-07-11 11:34:0443// Helper to see if a frame currently has storage access using
44// document.hasStorageAccess(). Returns true if the promise resolves with a
45// value of true; false otherwise.
46bool HasStorageAccessForFrame(content::RenderFrameHost* frame);
Brandon Maslen6134c852020-05-18 21:45:2147
48} // namespace test
49} // namespace storage
50#endif // CHROME_BROWSER_NET_STORAGE_TEST_UTILS_H_