Skip to content

Commit 407a36e

Browse files
committed
docs(policy-json): add Common use cases section with browsers.create() examples
1 parent b3e776f commit 407a36e

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

browsers/pools/policy-json.mdx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,72 @@ The example above demonstrates setting a default homepage and managed bookmarks.
174174
| `BookmarkBarEnabled` | `boolean` | Shows the bookmark bar |
175175
| `ManagedBookmarks` | `array` | Pre-configured bookmarks. Supports folders via nested `children` arrays |
176176

177+
## Common use cases
178+
179+
`chrome_policy` is also accepted directly on `browsers.create()` when you don't need a reserved pool. The examples below use that path.
180+
181+
### Allow pop-ups
182+
183+
Chrome's default blocks pop-ups, which breaks sites that open download dialogs or OAuth windows in a new window. Set `DefaultPopupsSetting` to `1` to allow them (`2` blocks).
184+
185+
<CodeGroup>
186+
```python Python
187+
from kernel import Kernel
188+
189+
kernel = Kernel()
190+
191+
browser = kernel.browsers.create(
192+
chrome_policy={
193+
"DefaultPopupsSetting": 1,
194+
}
195+
)
196+
```
197+
198+
```typescript Typescript/Javascript
199+
import Kernel from '@onkernel/sdk';
200+
201+
const kernel = new Kernel();
202+
203+
const browser = await kernel.browsers.create({
204+
chrome_policy: {
205+
DefaultPopupsSetting: 1,
206+
},
207+
});
208+
```
209+
</CodeGroup>
210+
211+
### Control file download behavior
212+
213+
When automating file downloads that trigger permission prompts, combine `DefaultPopupsSetting: 1` with `DownloadRestrictions: 0` to allow all downloads.
214+
215+
<CodeGroup>
216+
```python Python
217+
from kernel import Kernel
218+
219+
kernel = Kernel()
220+
221+
browser = kernel.browsers.create(
222+
chrome_policy={
223+
"DefaultPopupsSetting": 1,
224+
"DownloadRestrictions": 0,
225+
}
226+
)
227+
```
228+
229+
```typescript Typescript/Javascript
230+
import Kernel from '@onkernel/sdk';
231+
232+
const kernel = new Kernel();
233+
234+
const browser = await kernel.browsers.create({
235+
chrome_policy: {
236+
DefaultPopupsSetting: 1,
237+
DownloadRestrictions: 0,
238+
},
239+
});
240+
```
241+
</CodeGroup>
242+
177243
## Available policies
178244

179245
Any policy listed in the [Chrome Enterprise policy documentation](https://chromeenterprise.google/policies/) can be used in the `chrome_policy` object. Refer to the official docs for the full list of supported policy names, types, and values.

0 commit comments

Comments
 (0)