1 <!DOCTYPE html> 2 <html> 3 <!-- 4 Copyright 2013 Google Inc. 5 6 Use of this source code is governed by a BSD-style license that can be 7 found in the LICENSE file. 8 --> 9 <head> 10 11 <title>Skia Unit Tests</title> 12 13 <script type="text/javascript"> 14 "use strict"; 15 16 var SkiaModule = null; // Global application object. 17 18 // Force a re-draw of the given element. 19 function refresh(elem) { 20 var old_display_style = elem.style.display; 21 elem.style.display = "none"; 22 elem.style.display = old_display_style; 23 } 24 25 // When the module loads, begin running the application. 26 function moduleDidLoad() { 27 SkiaModule = document.getElementById("skia_nacl"); 28 run(); 29 } 30 31 function handleMessage(message_event) { 32 var skdebugf_cmd = "SkDebugf:"; 33 if (message_event.data.indexOf(skdebugf_cmd) == 0) { 34 var msg_contents = message_event.data.slice(skdebugf_cmd.length) 35 //console.log("Skia: " + msg_contents); 36 var log_textarea = document.getElementById("log_textarea") 37 log_textarea.value += msg_contents; 38 log_textarea.scrollTop = log_textarea.scrollHeight; 39 refresh(log_textarea); 40 } else { 41 alert(message_event.data); 42 } 43 } 44 45 // Run the application. 46 function run() { 47 if (SkiaModule) { 48 var cmd = "init"; 49 SkiaModule.postMessage(cmd); 50 } else { 51 alert("The Skia module has not properly loaded..."); 52 } 53 } 54 </script> 55 </head> 56 <body> 57 58 <h1>Skia Unit Tests</h1> 59 <p> 60 <textarea id="log_textarea" rows="2" cols="2" readonly style="width:100%; height:500px; resize:none;"></textarea> 61 </p> 62 <p> 63 <div id="listener"> 64 <script type="text/javascript"> 65 var listener = document.getElementById('listener'); 66 listener.addEventListener('load', moduleDidLoad, true); 67 listener.addEventListener('message', handleMessage, true); 68 </script> 69 70 <embed name="nacl_module" 71 id="skia_nacl" 72 width=0 height=0 73 src="tests.nmf" 74 type="application/x-nacl" /> 75 </div> 76 </p> 77 </body> 78 </html> 79