imcplugin: Clarify workaround for handling files that don't exist
[nativeclient.git] / imcplugin / hello.html
blob168be30952cce444b29d56c39b9ae9e7ed73b7d4
2 Testing glibc...
4 <object id="plugin" type="application/x-nacl-imc">Plugin not working</object>
6 <script type="text/javascript">
7 var prefix_dir = "../install-stubout";
8 var args = ["--library-path", "/lib", "../glibc/hellow-dyn"];
9 var plugin;
10 var proc;
12 function receive(message) {
13 var header = message.substring(0, 4);
14 if(header == "Open") {
15 open(message.substring(4));
17 else {
18 dump("unrecognised message: " + message + "\n");
22 /* imcplugin currently does not respond if we ask for a file that doesn't
23 exist. As a temporary workaround, we whitelist allowed files. */
24 files = [
25 "/lib/libc.so.6",
26 "/lib/libdl.so.2",
27 "/lib/libutil.so.1",
28 "/lib/libm.so.6",
29 "../glibc/hellow-dyn",
31 function have_file(filename) {
32 for(var i = 0; i < files.length; i++)
33 if(filename == files[i])
34 return true;
35 return false;
38 function open(filename) {
39 dump("open: " + filename + "\n");
40 if(!have_file(filename)) {
41 proc.send("", []);
43 else {
44 if(filename.substring(0, 5) == "/lib/") {
45 filename = prefix_dir + filename;
47 plugin.get_file(filename, function(file) {
48 proc.send("", [file]);
49 });
53 function onload() {
54 try {
55 plugin = document.getElementById("plugin");
56 plugin.get_file(prefix_dir + "/lib/ld-linux.so.2", function(file) {
57 proc = plugin.launch(file, args, receive);
58 });
60 catch(e) {
61 dump(e + "\n");
64 window.onload = onload;
65 </script>