or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

constants.mdcontent-management.mddom-manipulation.mdindex.mdjavascript-integration.mdlegacy-webkit.mdmodern-webkit.mdnavigation.md

constants.mddocs/

0

# Constants and Enumerations

1

2

This document covers navigation types, error codes, content policies, and other enumerated values used throughout the WebKit and JavaScriptCore frameworks. These constants are essential for handling navigation events, error conditions, and configuring framework behavior.

3

4

## WebKit Navigation Constants

5

6

### Modern WK Navigation Types

7

8

Navigation type constants for WKNavigationAction.

9

10

```python { .api }

11

# WK Navigation Types

12

WKNavigationTypeLinkActivated = 0 # User activated a link

13

WKNavigationTypeFormSubmitted = 1 # User submitted a form

14

WKNavigationTypeBackForward = 2 # User used back/forward navigation

15

WKNavigationTypeReload = 3 # User reloaded the page

16

WKNavigationTypeFormResubmitted = 4 # User resubmitted a form

17

WKNavigationTypeOther = -1 # Other navigation types

18

```

19

20

### WK Navigation Policies

21

22

Policy constants for navigation and response handling.

23

24

```python { .api }

25

# WK Navigation Action Policies

26

WKNavigationActionPolicyCancel = 0 # Cancel the navigation

27

WKNavigationActionPolicyAllow = 1 # Allow the navigation

28

WKNavigationActionPolicyDownload = 2 # Download the resource instead

29

30

# WK Navigation Response Policies

31

WKNavigationResponsePolicyCancel = 0 # Cancel loading the response

32

WKNavigationResponsePolicyAllow = 1 # Allow loading the response

33

WKNavigationResponsePolicyDownload = 2 # Download the response

34

```

35

36

### Legacy Web Navigation Types

37

38

Navigation type constants for legacy WebView components.

39

40

```python { .api }

41

# Web Navigation Types (Legacy)

42

WebNavigationTypeLinkClicked = 0 # User clicked a link

43

WebNavigationTypeFormSubmitted = 1 # User submitted a form

44

WebNavigationTypeBackForward = 2 # Back/forward navigation

45

WebNavigationTypeReload = 3 # Page reload

46

WebNavigationTypeFormResubmitted = 4 # Form resubmission

47

WebNavigationTypeOther = 5 # Other navigation

48

```

49

50

## WebKit Error Constants

51

52

### WK Error Codes

53

54

Error codes for WebKit operations and failures.

55

56

```python { .api }

57

# WK Error Codes

58

WKErrorUnknown = 1 # Unknown error

59

WKErrorWebContentProcessTerminated = 2 # Web content process crashed

60

WKErrorWebViewInvalidated = 3 # Web view was invalidated

61

WKErrorJavaScriptExceptionOccurred = 4 # JavaScript exception occurred

62

WKErrorJavaScriptResultTypeIsUnsupported = 5 # Unsupported JavaScript result type

63

WKErrorContentRuleListStoreCompileFailed = 6 # Content rule compilation failed

64

WKErrorContentRuleListStoreLookUpFailed = 7 # Content rule lookup failed

65

WKErrorContentRuleListStoreRemoveFailed = 8 # Content rule removal failed

66

WKErrorContentRuleListStoreVersionMismatch = 9 # Content rule version mismatch

67

WKErrorAttributedStringContentFailedToLoad = 10 # Attributed string content loading failed

68

WKErrorAttributedStringContentLoadTimedOut = 11 # Attributed string content load timeout

69

```

70

71

### WK Error Domain

72

73

```python { .api }

74

WKErrorDomain = "WKErrorDomain" # Error domain for WebKit errors

75

```

76

77

## User Script Constants

78

79

### User Script Injection Times

80

81

When to inject user scripts into web pages.

82

83

```python { .api }

84

# WK User Script Injection Times

85

WKUserScriptInjectionTimeAtDocumentStart = 0 # Inject after document creation but before loading

86

WKUserScriptInjectionTimeAtDocumentEnd = 1 # Inject after document load completion

87

```

88

89

## Website Data Type Constants

90

91

### Data Types for Website Data Management

92

93

```python { .api }

94

# WK Website Data Types

95

WKWebsiteDataTypeCookies = "WKWebsiteDataTypeCookies"

96

WKWebsiteDataTypeDiskCache = "WKWebsiteDataTypeDiskCache"

97

WKWebsiteDataTypeMemoryCache = "WKWebsiteDataTypeMemoryCache"

98

WKWebsiteDataTypeOfflineWebApplicationCache = "WKWebsiteDataTypeOfflineWebApplicationCache"

99

WKWebsiteDataTypeSessionStorage = "WKWebsiteDataTypeSessionStorage"

100

WKWebsiteDataTypeLocalStorage = "WKWebsiteDataTypeLocalStorage"

101

WKWebsiteDataTypeWebSQLDatabases = "WKWebsiteDataTypeWebSQLDatabases"

102

WKWebsiteDataTypeIndexedDBDatabases = "WKWebsiteDataTypeIndexedDBDatabases"

103

WKWebsiteDataTypeServiceWorkerRegistrations = "WKWebsiteDataTypeServiceWorkerRegistrations"

104

WKWebsiteDataTypeFetchCache = "WKWebsiteDataTypeFetchCache"

105

WKWebsiteDataTypeFileSystem = "WKWebsiteDataTypeFileSystem"

106

WKWebsiteDataTypeSearchFieldRecentSearches = "WKWebsiteDataTypeSearchFieldRecentSearches"

107

WKWebsiteDataTypeMediaKeys = "WKWebsiteDataTypeMediaKeys"

108

WKWebsiteDataTypeHashSalt = "WKWebsiteDataTypeHashSalt"

109

```

110

111

### Media and Capture Constants

112

113

```python { .api }

114

# WK Media Capture States

115

WKMediaCaptureStateNone = 0

116

WKMediaCaptureStateActive = 1

117

WKMediaCaptureStateMuted = 2

118

119

# WK Audiovisual Media Types

120

WKAudiovisualMediaTypeNone = 0

121

WKAudiovisualMediaTypeAudio = 1

122

WKAudiovisualMediaTypeVideo = 2

123

WKAudiovisualMediaTypeAll = -1

124

125

# WK Content Mode

126

WKContentModeRecommended = 0

127

WKContentModeMobile = 1

128

WKContentModeDesktop = 2

129

130

# WK Selection Granularity

131

WKSelectionGranularityDynamic = 0

132

WKSelectionGranularityCharacter = 1

133

134

# WK Data Detector Types

135

WKDataDetectorTypeNone = 0

136

WKDataDetectorTypePhoneNumber = 1

137

WKDataDetectorTypeLink = 2

138

WKDataDetectorTypeAddress = 4

139

WKDataDetectorTypeCalendarEvent = 8

140

WKDataDetectorTypeTrackingNumber = 16

141

WKDataDetectorTypeFlightNumber = 32

142

WKDataDetectorTypeLookupSuggestion = 64

143

WKDataDetectorTypeAll = -1

144

145

# WK Permission Decision

146

WKPermissionDecisionPrompt = 0

147

WKPermissionDecisionGrant = 1

148

WKPermissionDecisionDeny = 2

149

```

150

151

## DOM Constants

152

153

### DOM Node Types

154

155

```python { .api }

156

# DOM Node Types

157

DOM_ELEMENT_NODE = 1

158

DOM_ATTRIBUTE_NODE = 2

159

DOM_TEXT_NODE = 3

160

DOM_CDATA_SECTION_NODE = 4

161

DOM_ENTITY_REFERENCE_NODE = 5

162

DOM_ENTITY_NODE = 6

163

DOM_PROCESSING_INSTRUCTION_NODE = 7

164

DOM_COMMENT_NODE = 8

165

DOM_DOCUMENT_NODE = 9

166

DOM_DOCUMENT_TYPE_NODE = 10

167

DOM_DOCUMENT_FRAGMENT_NODE = 11

168

DOM_NOTATION_NODE = 12

169

```

170

171

### DOM CSS Value Types

172

173

```python { .api }

174

# DOM CSS Value Types

175

DOM_CSS_INHERIT = 0

176

DOM_CSS_PRIMITIVE_VALUE = 1

177

DOM_CSS_VALUE_LIST = 2

178

DOM_CSS_CUSTOM = 3

179

```

180

181

### DOM Event Constants

182

183

```python { .api }

184

# DOM Event Phase Constants

185

DOM_CAPTURING_PHASE = 1

186

DOM_AT_TARGET = 2

187

DOM_BUBBLING_PHASE = 3

188

189

# DOM Key Location Constants

190

DOM_KEY_LOCATION_STANDARD = 0

191

DOM_KEY_LOCATION_LEFT = 1

192

DOM_KEY_LOCATION_RIGHT = 2

193

DOM_KEY_LOCATION_NUMPAD = 3

194

```

195

196

## JavaScriptCore Constants

197

198

### JavaScript Type Constants

199

200

```python { .api }

201

# JavaScript Types (JSType enum)

202

kJSTypeUndefined = 0

203

kJSTypeNull = 1

204

kJSTypeBoolean = 2

205

kJSTypeNumber = 3

206

kJSTypeString = 4

207

kJSTypeObject = 5

208

kJSTypeSymbol = 6

209

kJSTypeBigInt = 7

210

```

211

212

### JavaScript Property Attributes

213

214

```python { .api }

215

# JavaScript Property Attributes

216

kJSPropertyAttributeNone = 0

217

kJSPropertyAttributeReadOnly = 2

218

kJSPropertyAttributeDontEnum = 4

219

kJSPropertyAttributeDontDelete = 8

220

```

221

222

### JavaScript Class Attributes

223

224

```python { .api }

225

# JavaScript Class Attributes

226

kJSClassAttributeNone = 0

227

kJSClassAttributeNoAutomaticPrototype = 2

228

```

229

230

### TypedArray Type Constants

231

232

```python { .api }

233

# TypedArray Types

234

kJSTypedArrayTypeInt8Array = 0

235

kJSTypedArrayTypeInt16Array = 1

236

kJSTypedArrayTypeInt32Array = 2

237

kJSTypedArrayTypeUint8Array = 3

238

kJSTypedArrayTypeUint8ClampedArray = 4

239

kJSTypedArrayTypeUint16Array = 5

240

kJSTypedArrayTypeUint32Array = 6

241

kJSTypedArrayTypeFloat32Array = 7

242

kJSTypedArrayTypeFloat64Array = 8

243

kJSTypedArrayTypeArrayBuffer = 9

244

kJSTypedArrayTypeNone = 10

245

kJSTypedArrayTypeBigInt64Array = 11

246

kJSTypedArrayTypeBigUint64Array = 12

247

kJSTypedArrayTypeDataView = 13

248

```

249

250

### JavaScript Property Descriptor Keys

251

252

```python { .api }

253

# Property Descriptor Keys (for Object.defineProperty)

254

JSPropertyDescriptorConfigurableKey = "configurable"

255

JSPropertyDescriptorEnumerableKey = "enumerable"

256

JSPropertyDescriptorGetKey = "get"

257

JSPropertyDescriptorSetKey = "set"

258

JSPropertyDescriptorValueKey = "value"

259

JSPropertyDescriptorWritableKey = "writable"

260

```

261

262

## WebKit Version Constants

263

264

### Version Numbers

265

266

```python { .api }

267

# WebKit Version Constants

268

WEBKIT_VERSION_1_0 = 256

269

WEBKIT_VERSION_1_1 = 272

270

WEBKIT_VERSION_1_2 = 288

271

WEBKIT_VERSION_1_3 = 304

272

WEBKIT_VERSION_2_0 = 512

273

WEBKIT_VERSION_3_0 = 768

274

WEBKIT_VERSION_3_1 = 784

275

WEBKIT_VERSION_4_0 = 1024

276

WEBKIT_VERSION_LATEST = 39321

277

```

278

279

## Notification Names

280

281

### WebView Notifications

282

283

```python { .api }

284

# WebView Progress Notifications

285

WebViewProgressStartedNotification = "WebViewProgressStartedNotification"

286

WebViewProgressEstimateChangedNotification = "WebViewProgressEstimateChangedNotification"

287

WebViewProgressFinishedNotification = "WebViewProgressFinishedNotification"

288

289

# WebView Editing Notifications

290

WebViewDidBeginEditingNotification = "WebViewDidBeginEditingNotification"

291

WebViewDidChangeNotification = "WebViewDidChangeNotification"

292

WebViewDidEndEditingNotification = "WebViewDidEndEditingNotification"

293

WebViewDidChangeTypingStyleNotification = "WebViewDidChangeTypingStyleNotification"

294

WebViewDidChangeSelectionNotification = "WebViewDidChangeSelectionNotification"

295

```

296

297

## Element Information Keys

298

299

### WebView Element Keys

300

301

```python { .api }

302

# Element Dictionary Keys (for hit testing results)

303

WebElementDOMNodeKey = "WebElementDOMNode"

304

WebElementFrameKey = "WebElementFrame"

305

WebElementImageKey = "WebElementImage"

306

WebElementImageAltStringKey = "WebElementImageAltString"

307

WebElementImageRectKey = "WebElementImageRect"

308

WebElementImageURLKey = "WebElementImageURL"

309

WebElementIsSelectedKey = "WebElementIsSelected"

310

WebElementLinkURLKey = "WebElementLinkURL"

311

WebElementLinkTargetFrameKey = "WebElementLinkTargetFrame"

312

WebElementLinkTitleKey = "WebElementLinkTitle"

313

WebElementLinkLabelKey = "WebElementLinkLabel"

314

WebElementSpellingToolTipKey = "WebElementSpellingToolTip"

315

WebElementTitleKey = "WebElementTitle"

316

WebElementLinkIsLiveKey = "WebElementLinkIsLive"

317

```

318

319

## Cache Model Constants

320

321

### WebView Cache Models

322

323

```python { .api }

324

# Cache Models for WebPreferences

325

WebCacheModelDocumentViewer = 0 # Appropriate for document viewer

326

WebCacheModelDocumentBrowser = 1 # Appropriate for document browser

327

WebCacheModelPrimaryWebBrowser = 2 # Appropriate for primary web browser

328

```

329

330

## Usage Examples

331

332

### Using Navigation Constants

333

334

```python

335

import WebKit

336

337

class NavigationDelegate:

338

def webView_decidePolicyForNavigationAction_decisionHandler_(self, web_view, action, handler):

339

navigation_type = action.navigationType()

340

341

if navigation_type == WebKit.WKNavigationTypeLinkActivated:

342

print("User clicked a link")

343

handler(WebKit.WKNavigationActionPolicyAllow)

344

elif navigation_type == WebKit.WKNavigationTypeFormSubmitted:

345

print("User submitted a form")

346

handler(WebKit.WKNavigationActionPolicyAllow)

347

else:

348

handler(WebKit.WKNavigationActionPolicyAllow)

349

```

350

351

### Using Error Constants

352

353

```python

354

import WebKit

355

356

class NavigationDelegate:

357

def webView_didFailNavigation_withError_(self, web_view, navigation, error):

358

error_code = error.code()

359

360

if error_code == WebKit.WKErrorWebContentProcessTerminated:

361

print("Web content process crashed - reloading")

362

web_view.reload()

363

elif error_code == WebKit.WKErrorJavaScriptExceptionOccurred:

364

print(f"JavaScript error: {error.localizedDescription()}")

365

else:

366

print(f"Navigation error: {error.localizedDescription()}")

367

```

368

369

### Using JavaScript Type Constants

370

371

```python

372

import JavaScriptCore

373

374

def handle_js_value(js_value, context):

375

value_type = JavaScriptCore.JSValueGetType(context, js_value)

376

377

if value_type == JavaScriptCore.kJSTypeString:

378

return "String value"

379

elif value_type == JavaScriptCore.kJSTypeNumber:

380

return "Number value"

381

elif value_type == JavaScriptCore.kJSTypeBoolean:

382

return "Boolean value"

383

elif value_type == JavaScriptCore.kJSTypeObject:

384

return "Object value"

385

elif value_type == JavaScriptCore.kJSTypeNull:

386

return "Null value"

387

elif value_type == JavaScriptCore.kJSTypeUndefined:

388

return "Undefined value"

389

else:

390

return "Unknown type"

391

```

392

393

These constants provide the foundation for handling WebKit and JavaScriptCore framework events, errors, and configuration throughout your application development.