Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
Brandon Maslen | 6134c85 | 2020-05-18 21:45:21 | [diff] [blame] | 2 | // 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 Maslen | 6134c85 | 2020-05-18 21:45:21 | [diff] [blame] | 10 | namespace content { |
Brandon Maslen | 6134c85 | 2020-05-18 21:45:21 | [diff] [blame] | 11 | class RenderFrameHost; |
| 12 | } // namespace content |
| 13 | |
| 14 | namespace storage { |
| 15 | namespace test { |
| 16 | |
Chris Fredrickson | f39f87b | 2022-07-11 11:34:04 | [diff] [blame] | 17 | // Gets the text content of a given frame. |
| 18 | std::string GetFrameContent(content::RenderFrameHost* frame); |
Brandon Maslen | 6134c85 | 2020-05-18 21:45:21 | [diff] [blame] | 19 | |
| 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 Fredrickson | 61269f5 | 2022-08-11 18:27:35 | [diff] [blame] | 22 | void SetStorageForFrame(content::RenderFrameHost* frame, bool include_cookies); |
Asami Doi | bcbe9af | 2021-03-24 04:50:52 | [diff] [blame] | 23 | void SetStorageForWorker(content::RenderFrameHost* frame); |
Chris Fredrickson | 61269f5 | 2022-08-11 18:27:35 | [diff] [blame] | 24 | void ExpectStorageForFrame(content::RenderFrameHost* frame, |
| 25 | bool include_cookies, |
| 26 | bool expected); |
Asami Doi | bcbe9af | 2021-03-24 04:50:52 | [diff] [blame] | 27 | void ExpectStorageForWorker(content::RenderFrameHost* frame, bool expected); |
Brandon Maslen | 6134c85 | 2020-05-18 21:45:21 | [diff] [blame] | 28 | |
| 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 |
| 31 | void SetCrossTabInfoForFrame(content::RenderFrameHost* frame); |
| 32 | void ExpectCrossTabInfoForFrame(content::RenderFrameHost* frame, bool expected); |
| 33 | |
| 34 | // Helper to request storage access for a frame using |
Chris Fredrickson | f39f87b | 2022-07-11 11:34:04 | [diff] [blame] | 35 | // document.requestStorageAccess(). Returns true if the promise resolves; false |
| 36 | // if it rejects. |
| 37 | bool RequestStorageAccessForFrame(content::RenderFrameHost* frame); |
Matt Reichhoff | 70f539f5 | 2022-08-19 21:35:01 | [diff] [blame] | 38 | // Helper to request storage access with a site override for a frame using |
Matt Reichhoff | ae4453f | 2022-09-26 22:39:31 | [diff] [blame^] | 39 | // document.requestStorageAccessForOrigin(origin). Returns true if the promise |
Matt Reichhoff | 70f539f5 | 2022-08-19 21:35:01 | [diff] [blame] | 40 | // resolves; false if it rejects. |
Matt Reichhoff | ae4453f | 2022-09-26 22:39:31 | [diff] [blame^] | 41 | bool RequestStorageAccessForOrigin(content::RenderFrameHost* frame, |
| 42 | const std::string& origin); |
Chris Fredrickson | f39f87b | 2022-07-11 11:34:04 | [diff] [
|