Brandon Maslen | 6134c85 | 2020-05-18 21:45:21 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors. All rights reserved. |
| 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 | |
| 10 | class GURL; |
| 11 | |
| 12 | namespace content { |
| 13 | class BrowserContext; |
| 14 | class RenderFrameHost; |
| 15 | } // namespace content |
| 16 | |
| 17 | namespace storage { |
| 18 | namespace test { |
| 19 | |
| 20 | // Helper to validate a given frame contains the |expected| contents as their |
| 21 | // document body. |
| 22 | void ExpectFrameContent(content::RenderFrameHost* frame, |
| 23 | const std::string& expected); |
| 24 | // Helper to validate a given for a given |context| and |host_url| that |
| 25 | // |expected| cookies are present. |
| 26 | void ExpectCookiesOnHost(content::BrowserContext* context, |
| 27 | const GURL& host_url, |
| 28 | const std::string& expected); |
| 29 | |
| 30 | // Helpers to set and check various types of storage on a given frame. Typically |
| 31 | // used on page like //chrome/test/data/browsing_data/site_data.html |
| 32 | void SetStorageForFrame(content::RenderFrameHost* frame); |
Asami Doi | bcbe9af | 2021-03-24 04:50:52 | [diff] [blame^] | 33 | void SetStorageForWorker(content::RenderFrameHost* frame); |
Brandon Maslen | 6134c85 | 2020-05-18 21:45:21 | [diff] [blame] | 34 | void ExpectStorageForFrame(content::RenderFrameHost* frame, bool expected); |
Asami Doi | bcbe9af | 2021-03-24 04:50:52 | [diff] [blame^] | 35 | void ExpectStorageForWorker(content::RenderFrameHost* frame, bool expected); |
Brandon Maslen | 6134c85 | 2020-05-18 21:45:21 | [diff] [blame] | 36 | |
| 37 | // Helpers to set and check various types of cross tab info for a given frame. |
| 38 | // Typically used on page like //chrome/test/data/browsing_data/site_data.html |
| 39 | void SetCrossTabInfoForFrame(content::RenderFrameHost* frame); |
| 40 | void ExpectCrossTabInfoForFrame(content::RenderFrameHost* frame, bool expected); |
| 41 | |
| 42 | // Helper to request storage access for a frame using |
| 43 | // document.requestStorageAccess() |
| 44 | void RequestStorageAccessForFrame(content::RenderFrameHost* frame, |
| 45 | bool should_resolve); |
| 46 | // Helper to validate if a frame currently has storage access using |
| 47 | // document.hasStorageAccess() |
| 48 | void CheckStorageAccessForFrame(content::RenderFrameHost* frame, |
| 49 | bool access_expected); |
| 50 | |
| 51 | } // namespace test |
| 52 | } // namespace storage |
| 53 | #endif // CHROME_BROWSER_NET_STORAGE_TEST_UTILS_H_ |