File tree 4 files changed +53
-5
lines changed
4 files changed +53
-5
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ <h1>engine262</h1>
49
49
50
50
< section id ="output-section ">
51
51
< h2 > Output:</ h2 >
52
- < textarea id ="output " cols =" 80 " autocomplete =" off " disabled > </ textarea >
52
+ < div id ="output "> </ div >
53
53
</ section >
54
54
</ main >
55
55
Original file line number Diff line number Diff line change @@ -52,14 +52,27 @@ function respawn(first = false) {
52
52
} ) ;
53
53
} else if ( data . type === 'console' ) {
54
54
if ( data . value . method === 'clear' ) {
55
- output . value = '' ;
55
+ const range = document . createRange ( ) ;
56
+ range . selectNodeContents ( output ) ;
57
+ range . deleteContents ( ) ;
56
58
} else {
59
+ const line = document . createElement ( 'span' ) ;
57
60
data . value . values . forEach ( ( v ) => {
58
- output . value += v ;
59
- output . value += ' ' ;
61
+ line . textContent += v ;
62
+ line . textContent += ' ' ;
60
63
} ) ;
61
- output . value += '\n' ;
64
+ const container = document . createElement ( 'div' ) ;
65
+ container . className = `log-${ data . value . method } ` ;
66
+ container . appendChild ( line ) ;
67
+ output . appendChild ( container ) ;
62
68
}
69
+ } else if ( data . type === 'unhandledRejection' ) {
70
+ const line = document . createElement ( 'span' ) ;
71
+ line . textContent = `Unhandled Rejection:\n${ data . value } ` ;
72
+ const container = document . createElement ( 'div' ) ;
73
+ container . className = 'log-error' ;
74
+ container . appendChild ( line ) ;
75
+ output . appendChild ( container ) ;
63
76
}
64
77
} ) ;
65
78
}
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
/* eslint-env worker */
4
+ /* eslint-disable no-restricted-globals */
4
5
5
6
importScripts ( 'https://unpkg.com/acorn@7.0.0/dist/acorn.js' ) ;
6
7
importScripts ( 'https://unpkg.com/nearley@2.16.0/lib/nearley.js' ) ;
@@ -29,6 +30,15 @@ addEventListener('message', ({ data }) => {
29
30
try {
30
31
initializeAgent ( {
31
32
features : [ ...state . get ( 'features' ) ] ,
33
+ promiseRejectionTracker ( promise , operation ) {
34
+ if ( operation === 'reject' ) {
35
+ postMessage ( {
36
+ type : 'unhandledRejection' ,
37
+ // eslint-disable-next-line no-use-before-define
38
+ value : inspect ( promise . PromiseResult , realm ) ,
39
+ } ) ;
40
+ }
41
+ } ,
32
42
} ) ;
33
43
} catch ( e ) {
34
44
// o.o
Original file line number Diff line number Diff line change @@ -47,16 +47,41 @@ textarea:disabled {
47
47
border : 1px solid black;
48
48
color : black;
49
49
}
50
+
50
51
# input-section , # output-section {
51
52
display : flex;
52
53
flex-direction : column;
53
54
flex-grow : 1 ;
54
55
flex-shrink : 1 ;
55
56
}
57
+
56
58
# output {
57
59
flex-grow : 1 ;
58
60
min-height : 200px ;
61
+ background-color : white;
62
+ border : 1px solid black;
63
+ font-family : monospace;
64
+ white-space : pre-wrap;
65
+ }
66
+ # output > div {
67
+ padding-left : 0.3em ;
68
+ }
69
+
70
+ [class *= "log" ] {
71
+ border-bottom : 1px solid black;
72
+ }
73
+
74
+ .log-warn {
75
+ background-color : yellow;
76
+ }
77
+
78
+ .log-debug {}
79
+
80
+ .log-error {
81
+ background-color : # FF000070 ;
59
82
}
83
+
84
+
60
85
# features {
61
86
margin : 0 ;
62
87
padding : 0 ;
You can’t perform that action at this time.
0 commit comments