| <!DOCTYPE html> |
| <html> |
| |
| <head> |
| <style> |
| body { |
| background-color: rgb(255, 255, 255); |
| font-family: Roboto; |
| font-size: 2em; |
| } |
| |
| .highlight { |
| background-color: rgb(0, 255, 0); |
| } |
| </style> |
| </head> |
| |
| <body> |
| <div>Previous exit status: <span id="status"></span></div> |
| <div id="menu"></div> |
| <script type="text/javascript"> |
| const crash_types = { |
| out_of_memory: 'Out of memory', |
| null_dereference: 'Null dereference', |
| illegal_instruction: 'Illegal instruction', |
| debugger: 'Invoke debugger', |
| quit: 'Quit the demo' |
| } |
| |
| const kIsDirty = "_exit_is_dirty"; |
| const kDirtyValue = "1" |
| |
| function log(str) { |
| console.log(str); |
| } |
| window.onunload = function () { |
| log("==Onunload called=="); |
| localStorage.removeItem(kIsDirty); |
| } |
| window.onload = function () { |
| log("==Onload called=="); |
| var menu = document.getElementById('menu'); |
| for (key in crash_types) { |
| console.log("key" + key); |
| var el = document.createElement('div'); |
| el.id = key; |
| el.textContent = crash_types[key]; |
| menu.appendChild(el); |
| } |
| clean_exit = localStorage.getItem(kIsDirty) == kDirtyValue ? "crashed" : "clean"; |
| localStorage.setItem(kIsDirty, kDirtyValue) |
| |
| var menu = document.getElementById('menu').children; |
| var index = 0; |
| |
| document.getElementById("status").textContent += clean_exit; |
| |
| function refresh() { |
| log("Refresh"); |
| var textBox = document.getElementById('textBox'); |
| for (let i = 0; i < menu.length; i++) { |
| if (i == index) { |
| menu[i].classList.add('highlight'); |
| } else { |
| menu[i].classList.remove('highlight'); |
| } |
| } |
| } |
| document.addEventListener('keydown', function (e) { |
| if ([37, 38, 32782, 32780].includes(e.keyCode)) { // left, up, android left, up |
| index -= 1; |
| } else if ([39, 40, 32781, 32783].includes(e.keyCode)) { //right, down, android right, down |
| index += 1; |
| } else if ([13, 32768].includes(e.keyCode)) { // enter, android enter |
| var crashType = menu[index].id; |
| if (crashType === "quit") { |
| log("Calling window.close()"); |
| window.close() |
| return; |
| } |
| if ('h5vcc' in window) { |
| log("Crashing with " + crashType); |
| h5vcc.crashLog.triggerCrash(crashType); |
| } else { |
| log("No h5vcc, will not crash " + crashType); |
| } |
| } |
| index = (index + menu.length) % menu.length; |
| refresh(); |
| }); |
| refresh(); |
| } |
| </script> |
| </body> |
| |
| </html> |