Repository navigation
Expand file tree
/
Copy pathwxpython.html
More file actions
602 lines (477 loc) · 19.2 KB
/
Copy pathwxpython.html
File metadata and controls
602 lines (477 loc) · 19.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>wxPython CEF 3 example (utf-8: ąś)</title>
<style>
body { font: 13px Segoe UI, Arial; line-height: 1.4em; }
pre { background: #ddd; font: 12px Consolas, Courier New; }
</style>
<script>
function ShowSource(func) {
if (!("sources" in window) || !(func in window.sources)) {
document.write("<pre style='color:red'>Source not found: "+
""+func+"</pre>");
return;
}
source = window.sources[func];
if (source.match(/^( )/)) {
source = source.replace(/^( )/g, "");
source = source.replace(/([\r\n])( )/g, "$1");
}
source = source.replace(/</g, "<");
source = source.replace(/>/g, ">");
document.write("<pre><code class='language-python'>"+
""+source+"</pre></code>");
}
</script>
<link href="prism.css" rel="stylesheet">
</head>
<body>
Use the mouse context menu to go Back/Forward in history navigation.
<h2>Table of contents</h2>
<ol>
<li><a href="#google-search">Google search</a></li>
<li><a href="#user-agent">User agent</a></li>
<li><a href="#popups">Popups</a></li>
<li><a href="#html5-video">HTML 5 video</a></li>
<li><a href="#browser-object">Browser object</a></li>
<li><a href="#frame-object">Frame object</a></li>
<li><a href="#javascript-bindings">Javascript bindings</a></li>
<li><a href="#javascript-callbacks">Javascript callbacks</a></li>
<li><a href="#python-callbacks">Python callbacks</a></li>
<li><a href="#display-handler">Display handler</a></li>
<li><a href="#keyboard-handler">Keyboard handler</a></li>
<li><a href="#request-handler">Request handler</a></li>
<li><a href="#cookie-tests">Cookie tests</a></li>
<li><a href="#load-handler">Load handler</a></li>
<li><a href="#javascript-dialog-handler">Javascript Dialog handler</a></li>
</ol>
<!-- ********************************************************************** -->
<!-- Google search -->
<!-- ********************************************************************** -->
<a name="google-search"></a>
<h2>Google search</h2>
<a href="http://www.google.com/">http://www.google.com/</a>
<!-- ********************************************************************** -->
<!-- User agent -->
<!-- ********************************************************************** -->
<a name="user-agent"></a>
<h2>User agent</h2>
<script>document.write(navigator.userAgent)</script>
<!-- ********************************************************************** -->
<!-- Popups -->
<!-- ********************************************************************** -->
<a name="popups"></a>
<h2>Popups</h2>
<ol>
<li><a href="javascript:window.open('wxpython.html')">
window.open('wxpython.html')</a>
</li>
<li><a target=_blank href="wxpython.html">
href="wxpython.html"</a>
</li>
</ol>
<h3>CreateAnotherBrowser</h3>
This will create a window on its own and embed browser in it.
When using "window.open" the window is created implicitilly
by CEF. You can intercept such popup creation using the
OnBeforePopup callback in LifespanHandler. You can return
True in OnBeforePopup and create popup window on your own
using the CreateAnotherBrowser function.
<script>ShowSource("CreateAnotherBrowser");</script>
<a href="javascript:external.CreateAnotherBrowser()">
external.CreateAnotherBrowser()</a>
<!-- ********************************************************************** -->
<!-- HTML5 video and accelerated content -->
<!-- ********************************************************************** -->
<a name="html5-video"></a>
<h2>HTML5 video and accelerated content</h2>
<a href="http://www.youtube.com/watch?v=siOHh0uzcuY&html5=True">
HTML 5 video</a><br>
<a href="http://mudcu.be/labs/JS1k/BreathingGalaxies.html">
Accelerated canvas</a><br>
<a href="http://www.webkit.org/blog-files/3d-transforms/poster-circle.html">
Accelerated layers</a><br>
<!-- ********************************************************************** -->
<!-- Browser object -->
<!-- ********************************************************************** -->
<a name="browser-object"></a>
<h2>Browser object</h2>
Tests for the Browser object methods.
<h3>GoBack</h3>
<script>ShowSource("GoBack");</script>
<a href="javascript:external.GoBack()">external.GoBack()</a>
<h3>GoForward</h3>
<script>ShowSource("GoForward");</script>
<a href="javascript:external.GoForward()">external.GoForward()</a>
<h3>LoadUrl, GetUrl</h3>
<script>ShowSource("_Browser_LoadUrl");</script>
<a href="javascript:window.open('data:text/html,Test#Browser.LoadUrl')">
window.open('data:text/html,Test#Browser.LoadUrl')</a>
<!-- ********************************************************************** -->
<!-- Frame object -->
<!-- ********************************************************************** -->
<a name="frame-object"></a>
<h2>Frame object</h2>
Tests for the Frame object methods. TODO.
<!-- ********************************************************************** -->
<!-- Javascript bindings -->
<!-- ********************************************************************** -->
<a name="javascript-bindings"></a>
<h2>Javascript bindings</h2>
<h3>PyPrint</h3>
<script>ShowSource("PyPrint");</script>
<a href="javascript:window.PyPrint('printing in python console from js')">
window.PyPrint('printing in python console from js')</a>
<br>
<h3>Window properties</h3>
<pre><code class="language-python">jsBindings.SetProperty("pyProperty", "This was set in Python")
jsBindings.SetProperty("pyConfig", ["This was set in Python",
{"name": "Nested dictionary", "isNested": True},
[1,"2", None]])
</code></pre>
<a href="javascript:window.alert(window.pyProperty)">
window.alert(window.pyProperty)</a><br>
<a href="javascript:window.alert(JSON.stringify(window.pyConfig))">
window.alert(JSON.stringify(window.pyConfig))</a>
<br>
<h3>Print</h3>
<script>ShowSource("Print");</script>
<a href="javascript:external.Print('printing again from js')">
external.Print('printing again from js')</a>
<br>
<h3>TestAllTypes</h3>
<script>ShowSource("TestAllTypes");</script>
<a href="javascript:external.TestAllTypes(undefined, null, true, 1,
((1<<31)>>>0), 2.14, 'Date not yet supported', 'string',
{key1: 1, key2: 2}, {key1: {'key1.1': 'nested object'}, 'key1.2': [1]},
[1, 2], [1, [2.1, 'nested array']], [{key1: [{}]}])">
external.TestAllTypes</a>
<small>(undefined, null, true, 1,
((1<<31)>>>0), 2.14, 'Date not yet supported', 'string',
{key1: 1, key2: 2}, {key1: {'key1.1': 'nested object'}, 'key1.2': [1]},
[1, 2], [1, [2.1, 'nested array']], [{key1: [{}]}])</small>
<br>
<h3>ExecuteFunction</h3>
<script>
function JavascriptAlert(message) { window.alert(message); }
</script>
<pre><code class="language-javascript"><script>
function JavascriptAlert(message) { window.alert(message); }
</script>
</code></pre>
<script>ShowSource("ExecuteFunction");</script>
<a href="javascript:external.ExecuteFunction('JavascriptAlert',
'python called from js and then js called from python')">
external.ExecuteFunction('JavascriptAlert',
'python called from js and then js called from python')</a>
<br>
<h3>GetSource, GetText</h3>
<script>ShowSource("Visit");</script>
<script>ShowSource("GetSource");</script>
<script>ShowSource("GetText");</script>
<a href="javascript:external.GetSource()">
external.GetSource()</a>
<br>
<a href="javascript:external.GetText()">
external.GetText()</a>
<!-- ********************************************************************** -->
<!-- Javascript callbacks -->
<!-- ********************************************************************** -->
<a name="javascript-callbacks"></a>
<h2>Javascript callbacks</h2>
<h3>TestJSCallback</h3>
<script>
function JSCallback(arg1) {
window.alert(arg1)
}
</script>
<pre><code class="language-javascript"><script>
function JSCallback(arg1) {
window.alert(arg1)
}
</script>
</code></pre>
<script>ShowSource("TestJSCallback");</script>
<a href="javascript:external.TestJSCallback(JSCallback)">
external.TestJSCallback(JSCallback)</a>
<h3>TestJSCallbackComplexArguments</h3>
<script>
function JSCallback2() {
window.alert(JSON.stringify(arguments))
}
</script>
<pre><code class="language-javascript"><script>
function JSCallback2() {
window.alert(JSON.stringify(arguments))
}
</script>
</code></pre>
<script>ShowSource("TestJSCallbackComplexArguments");</script>
<a href="javascript:external.TestJSCallbackComplexArguments(
{'myCallback':JSCallback2})">
external.TestJSCallbackComplexArguments({"myCallback": JSCallback2})
</a>
<!-- ********************************************************************** -->
<!-- Python callbacks -->
<!-- ********************************************************************** -->
<a name="python-callbacks"></a>
<h2>Python callbacks</h2>
<h3>TestPythonCallback</h3>
<script>
function JSCallback3(pyCallback) {
pyCallback(1, 2.14, "string", [1, [2, {"key": "value"}]], {"list": [1,2]});
}
</script>
<pre><code class="language-javascript"><script>
function JSCallback3(pyCallback) {
pyCallback(1, 2.14, "string", [1, [2, {"key": "value"}]], {"list": [1,2]});
}
</script>
</code></pre>
<script>ShowSource("TestPythonCallback");</script>
<script>ShowSource("PyCallback");</script>
<a href="javascript:external.TestPythonCallback(JSCallback3)">
external.TestPythonCallback(JSCallback3)</a>
<!-- ********************************************************************** -->
<!-- Display handler -->
<!-- ********************************************************************** -->
<a name="display-handler"></a>
<h2>Display handler</h2>
<h3>OnAddressChange</h3>
<script>ShowSource("OnAddressChange");</script>
See messages in the console during loading of a webpage.
<h3>OnTitleChange</h3>
<script>ShowSource("OnTitleChange");</script>
See messages in the console during loading of a webpage.
<h3>OnTooltip</h3>
<script>ShowSource("OnTooltip");</script>
See messages in the console when hovering over a google logo:
<a href="http://www.google.com/">http://www.google.com/</a>
<h3>OnStatusMessage</h3>
<script>ShowSource("OnStatusMessage");</script>
See messages in the console when hovering over links.
<h3>OnConsoleMessage</h3>
<script>ShowSource("OnConsoleMessage");</script>
Try this:
<a href="http://patik.com/code/console-log-polyfill/">
http://patik.com/code/console-log-polyfill/</a>
<!-- ********************************************************************** -->
<!-- Keyboard handler -->
<!-- ********************************************************************** -->
<a name="keyboard-handler"></a>
<h2>Keyboard handler</h2>
<p>
Press F5 to reload the page.<br>
On Linux it is required to click anywhere in the window first
so that keyboard focus is set. See Issue 77 in the CEF Python
Issue Tracker.
</p>
<script>ShowSource("OnPreKeyEvent");</script>
<script>ShowSource("OnKeyEvent");</script>
<!-- ********************************************************************** -->
<!-- Request handler -->
<!-- ********************************************************************** -->
<a name="request-handler"></a>
<h2>Request handler</h2>
<h3>OnBeforeResourceLoad</h3>
<script>ShowSource("OnBeforeResourceLoad");</script>
See messages in the console.
<h3>OnResourceRedirect</h3>
<script>ShowSource("OnResourceRedirect");</script>
Try this:
<a href="http://tinyurl.com/google404redirect">
http://tinyurl.com/google404redirect</a>
<h3>GetAuthCredentials</h3>
<script>ShowSource("GetAuthCredentials");</script>
Try this:
<a href="http://browserspy.dk/password-ok.php">
http://browserspy.dk/password-ok.php</a>
<h3>OnQuotaRequest</h3>
<script>ShowSource("OnQuotaRequest");</script>
<script>
function DoRequestQuota() {
// Request Quota (only for File System API)
try {
navigator.webkitPersistentStorage.requestQuota(PERSISTENT, 1024*1024,
function(bytes){ window.alert("Granted bytes: "+bytes);},
function(error){ window.alert(error); });
} catch(e) {
navigator.webkitPersistentStorage.requestQuota(1024*1024,
function(bytes){ window.alert("Granted bytes: "+bytes);},
function(error){ window.alert(error); });
}
}
</script>
<pre><code class="language-javascript"><script>
function DoRequestQuota() {
// Request Quota (only for File System API)
try {
navigator.webkitPersistentStorage.requestQuota(PERSISTENT, 1024*1024,
function(bytes){ window.alert("Granted bytes: "+bytes);},
function(error){ window.alert(error); });
} catch(e) {
navigator.webkitPersistentStorage.requestQuota(1024*1024,
function(bytes){ window.alert("Granted bytes: "+bytes);},
function(error){ window.alert(error); });
}
}
</script>
</code></pre>
Try this:
<a href="https://googledrive.com/host/0B1di2XiBBfacMnhRRkI1YlotUEk/requestquota.html">
https://googledrive.com/host/0B1di2XiBBfacMnhRRkI1YlotUEk/requestquota.html</a>
<h3>OnProtocolExecution</h3>
<script>ShowSource("OnProtocolExecution");</script>
Try this:
<a href="magnet:?xt=urn:btih:a4224b45b27f436374391379cc5c7e629e2e5189">
magnet:?xt=urn:btih:a4224b45b27f436374391379cc5c7e629e2e5189</a>
<h3>_OnBeforePluginLoad</h3>
<script>ShowSource("_OnBeforePluginLoad");</script>
Try OnBeforePluginLoad() with Flash:
<a href="http://www.adobe.com/software/flash/about/">
http://www.adobe.com/software/flash/about/</a>
<h3>_OnCertificateError</h3>
<script>ShowSource("_OnCertificateError");</script>
The url below won't be allowed. Click twice "Back" from context menu to return back
here after visiting the url:<br>
<a href="https://tv.eurosport.com/do-not-allow">
https://tv.eurosport.com/do-not-allow</a>
<br>
This url will be allowed:<br>
<a href="https://tv.eurosport.com/">
https://tv.eurosport.com/</a>
<h3>OnRendererProcessTerminated</h3>
<script>ShowSource("OnRendererProcessTerminated");</script>
Try to terminate the "subprocess.exe" renderer process through
task manager.
<h3>OnPluginCrashed</h3>
<script>ShowSource("OnPluginCrashed");</script>
No test for that yet.
<!-- ********************************************************************** -->
<!-- Cookie tests -->
<!-- ********************************************************************** -->
<a name="cookie-tests"></a>
<h2>Cookie tests</h2>
See messages in the console.
<h3>GetCookieManager</h3>
<script>ShowSource("GetCookieManager");</script>
RequestHandler.GetCookieManager() - an example of having an unique
cookie manager for each browser.
<ol>
<li>Visit the url below and set some cookies. Use "Back" from
context menu to get back here (you might have to click "Back"
multiple times).<br>
Visit it in the current browser:<br>
<a href="http://www.html-kit.com/tools/cookietester/">
http://www.html-kit.com/tools/cookietester/</a>
<br>
Or visit it in a js popup:<br>
<a href="javascript:window.open('http://www.html-kit.com/tools/cookietester/')">
javascript:window.open('http://www.html-kit.com/tools/cookietester/')</a>
</li>
<li>Open cookietester in a popup:<br>
<a href="javascript:external.CreateAnotherBrowser('http://www.html-kit.com/tools/cookietester/')">
javascript:external.CreateAnotherBrowser('http://www.html-kit.com/tools/cookietester/')</a>
</li>
</ol>
<p>
Popup browsers created javascript's window.open share
the same renderer process and request context. If you want
to have separate cookie managers for popups created using
window.open then you have to implement the
LifespanHandler.`OnBeforePopup` callback. Return True in that
callback to cancel popup creation and instead create the
window on your own and embed browser in it. The CreateAnotherBrowser()
function from the wxpython example does that.
</p>
<h3>VisitAllCookies</h3>
<script>ShowSource("VisitAllCookies");</script>
Visit all cookies:
<a href="javascript:external.VisitAllCookies()">external.VisitAllCookies()</a>
<br><br>
Note: visit some http:// webpage first, otherwise cookie manager is not
yet created.
<br>
<h3>VisitUrlCookies</h3>
<script>ShowSource("VisitUrlCookies");</script>
Visit a subset of cookies for the given url:
<a href="javascript:external.VisitUrlCookies()">
external.VisitUrlCookies("http://www.html-kit.com/tools/cookietester/")</a>
<br>
<h3>SetCookie</h3>
<script>ShowSource("SetCookie");</script>
Set a cookie:
<a href="javascript:external.SetCookie()">external.SetCookie()</a>
<br>
<h3>DeleteCookies</h3>
<script>ShowSource("DeleteCookies");</script>
Delete the single cookie previously created via SetCookie():
<a href="javascript:external.DeleteCookies()">
external.DeleteCookies()</a>
<br>
<!-- ********************************************************************** -->
<!-- Load handler -->
<!-- ********************************************************************** -->
<a name="load-handler"></a>
<h2>Load Handler</h2>
See messages in the console during loading of a webpage.
<h3>OnLoadingStateChange</h3>
<script>ShowSource("OnLoadingStateChange");</script>
<h3>OnLoadStart</h3>
<script>ShowSource("OnLoadStart");</script>
<h3>OnLoadEnd</h3>
<script>ShowSource("OnLoadEnd");</script>
<h3>OnLoadError</h3>
<script>ShowSource("OnLoadError");</script>
Try this:
<a href="http://www.non-existent.nono/">
http://www.non-existent.nono/</a>
<br><br>
Note: after you see the custom error message you have to hit
twice the Back from the context menu, to get back to this page.
<!-- ********************************************************************** -->
<!-- Javascript dialog handler -->
<!-- ********************************************************************** -->
<a name="javascript-dialog-handler"></a>
<h2>Javascript Dialog Handler</h2>
See messages in the console.
<h3>OnJavascriptDialog</h3>
<script>ShowSource("OnJavascriptDialog");</script>
<a href="javascript:alert('test js dialog handler')">
alert('Test js dialog handler')
</a>
<h3>OnBeforeUnloadJavascriptDialog</h3>
<script>ShowSource("OnBeforeUnloadJavascriptDialog");</script>
<script>
function TestOnBeforeUnloadJavascriptDialog() {
window.onbeforeunload = function() {
return 'Testing the OnBeforeUnloadJavascriptDialog() callback';
}
location.href = "wxpython.html";
}
</script>
<pre><code class="language-javascript"><script>
function TestOnBeforeUnloadJavascriptDialog() {
window.onbeforeunload = function() {
return 'Testing the OnBeforeUnloadJavascriptDialog() callback';
}
location.href = "wxpython.html";
}
</script>
</code></pre>
<a href="javascript:TestOnBeforeUnloadJavascriptDialog()">
TestOnBeforeUnloadJavascriptDialog()
</a>
<h3>OnResetJavascriptDialogState</h3>
<script>ShowSource("OnResetJavascriptDialogState");</script>
<h3>OnJavascriptDialogClosed</h3>
<script>ShowSource("OnJavascriptDialogClosed");</script>
<!-- ********************************************************************** -->
<!-- Other -->
<!-- ********************************************************************** -->
<a name="test-hash"></a>
<script src="prism.js"></script>
</body>
</html>