1 var tabs = require("sdk/tabs");
2 const {Cu} = require("chrome");
4 for (i = 0; i < 10; i++) {
8 console.log("About to load ctypes");
9 Cu.import("resource://gre/modules/ctypes.jsm");
10 console.log(" ... loaded.");
15 // TODO: detect which OS we're running, and proactively search for the
16 // correct library name.
17 console.log("About to load libjsongssapi");
19 json_gssapi = ctypes.open("libjsongssapi.so");
23 json_gssapi = ctypes.open("libjsongssapi.dll");
26 console.log(" ... " + e);
29 console.log(" ... loaded.");
31 console.log("Declaring the call_gss function:");
32 const gss_request = json_gssapi.declare("gss_request",
36 console.log(" ... declared.");
39 console.log("Calling import_name");
41 reply = call_gss("{\"method\":\"gss_import_name\",\"arguments\":{\"input_name\":\"HTTP@localhost\",\"input_name_type\":\"{1 2 840 113554 1 2 1 4 }\"}}");
42 console.log(" ... Reply: " + reply.readString());
46 var self = require("sdk/self");
47 var data = require("sdk/self").data;
48 var pageMod = require("sdk/page-mod");
52 contentScriptFile: [data.url("navigator.gss.js")],
53 contentScriptWhen: "ready"
58 function invokeNativeGSS(msg)
64 // Deal with the cookies in the message
65 if ( typeof(msg.cookies) == 'undefined')
69 appTag = msg.cookies.app_tag;
71 // Send the message to the NativePort / command line
73 '[' + appTag + '] About to invoke native function: [' +
74 JSON.stringify(msg) + ']'
76 reply = gss_request( JSON.stringify(msg) );
77 response = JSON.parse(reply.readString() );
78 console.info('[' + appTag + '] ... native function invoked.');
79 console.info('[' + appTag + '] ... returned: ' + response);
84 tabs.on("ready", function(tab) {
85 app = tab.attach({ contentScriptFile: data.url("navigator.gss.js") });
86 app.port.on("gss_request", function(message) {
87 var response = invokeNativeGSS(message);
88 app.port.emit("gss_response", response);