THRIFT-2355 Add SSL and Web Socket Support to Node and JavaScript
Patch: Randy Abernethy
diff --git a/lib/js/test/README b/lib/js/test/README
new file mode 100644
index 0000000..6923794
--- /dev/null
+++ b/lib/js/test/README
@@ -0,0 +1,63 @@
+Thrift Javascript Library
+=========================
+This browser based Apache Thrift implementation supports
+RPC clients using the JSON protocol over Http[s] with XHR.
+
+License
+-------
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+
+Test Servers
+------------
+drwxr-xr-x 2 randy randy  4096 Feb  8 15:44 sec
+-rw-r--r-- 1 randy randy  2183 Feb  9 04:01 server_http.js
+-rw-r--r-- 1 randy randy  2386 Feb  9 05:39 server_https.js
+
+server_http.js is a Node.js web server which support the
+standard Apache Thrift test suite (thrift/test/ThriftTest.thrift).
+The server supports Apache Thrift XHR and WebSocket clients.
+
+server_https.js is the same but uses SSL/TLS. The sec directory
+contains the server key and certificate used by the ssl server.
+Both of these servers support WebSocket (the http: supports ws:,
+and the https: support wss:).
+
+To run the test servers use: $ make check (requires
+the Apache Thrift Java branch and make check must have
+been run in thrift/lib/java previously) or run the grunt
+ build in the parent js directory (see README there).
+ 
+Test Clients
+------------
+-rw-r--r-- 1 randy randy 13558 Feb  9 07:18 test-async.js
+-rw-r--r-- 1 randy randy  5724 Feb  9 03:45 test_handler.js
+-rwxr-xr-x 1 randy randy  2719 Feb  9 06:04 test.html
+-rw-r--r-- 1 randy randy  4611 Feb  9 06:05 test-jq.js
+-rwxr-xr-x 1 randy randy 12153 Feb  9 06:04 test.js
+-rw-r--r-- 1 randy randy  2593 Feb  9 06:16 test-nojq.html
+-rw-r--r-- 1 randy randy  1450 Feb  9 06:14 test-nojq.js
+-rw-r--r-- 1 randy randy  2847 Feb  9 06:31 testws.html
+
+There are three html test driver files, all of which are
+QUnit based. test.html test the Apache Thrift jQuery
+generated code (thrift -gen js:jquery). The test-nojq.html
+Runs almost identical tests against normal JavaScript builds
+(thrift -gen js). Both of the previous tests use the XHR 
+transport. The testws.html runs similar tests using the
+WebSocket transport. The test*.js files are loaded by the
+html drivers and contain the actualApache Thrift tests.
diff --git a/lib/js/test/server_http.js b/lib/js/test/server_http.js
index 623a979..01174bc 100644
--- a/lib/js/test/server_http.js
+++ b/lib/js/test/server_http.js
@@ -39,14 +39,14 @@
 	handler: ThriftTestHandler

 };

 

-var StaticHttpThriftServerOptions = {

+var ThriftWebServerOptions = {

 	staticFilePath: ".",

 	services: {

 		"/service": ThriftTestSvcOpt

 	}

 };

 

-var server = thrift.createStaticHttpThriftServer(StaticHttpThriftServerOptions);

+var server = thrift.createWebServer(ThriftWebServerOptions);

 var port = 8088;

 server.listen(port);

 console.log("Serving files from: " + __dirname);

diff --git a/lib/js/test/server_https.js b/lib/js/test/server_https.js
new file mode 100644
index 0000000..28f0585
--- /dev/null
+++ b/lib/js/test/server_https.js
@@ -0,0 +1,62 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements. See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership. The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License. You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied. See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+

+//This HTTP server is designed to server the test.html browser

+//  based JavaScript test page (which must be in the current directory). 

+//  This server also supplies the Thrift based test service, which depends

+//  on the standard ThriftTest.thrift IDL service (which must be compiled

+//  for Node and browser based JavaScript in ./gen-nodejs and ./gen-js

+//  respectively). The current directory must also include the browser

+//  support libraries for test.html (jquery.js, qunit.js and qunit.css

+//  in ./build/js/lib).

+

+var fs = require("fs");

+var thrift = require('../../nodejs/lib/thrift');

+var TBufferedTransport = require('../../nodejs/lib/thrift/transport').TBufferedTransport;

+var TJSONProtocol = require('../../nodejs/lib/thrift/protocol').TJSONProtocol;

+var ThriftTestSvc = require('./gen-nodejs/ThriftTest.js');

+var ThriftTestHandler = require('./test_handler').ThriftTestHandler;

+

+//Setup the I/O stack options for the ThriftTest service

+var ThriftTestSvcOpt = {

+	transport: TBufferedTransport,

+	protocol: TJSONProtocol,

+	cls: ThriftTestSvc,

+	handler: ThriftTestHandler

+};

+

+var ThriftWebServerOptions = {

+	staticFilePath: ".",

+	tlsOptions: {

+      key: fs.readFileSync("../../../test/keys/server.key"),

+      cert: fs.readFileSync("../../../test/keys/server.crt")

+    },	

+	services: {

+		"/service": ThriftTestSvcOpt

+	}

+};

+

+var server = thrift.createWebServer(ThriftWebServerOptions);

+var port = 8089;

+server.listen(port);

+console.log("Serving files from: " + __dirname);

+console.log("Http/Thrift Server running on port: " + port);

+

+

+

diff --git a/lib/js/test/test-async.js b/lib/js/test/test-async.js
new file mode 100644
index 0000000..4935fea
--- /dev/null
+++ b/lib/js/test/test-async.js
@@ -0,0 +1,347 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ /* jshint -W100 */
+ 
+/*
+ * Fully Async JavaScript test suite for ThriftTest.thrift. 
+ * These tests are designed to exercise the WebSocket transport
+ * (which is exclusively async).
+ *
+ * To compile client code for this test use:
+ *      $ thrift -gen js ThriftTest.thrift
+ */
+
+
+
+// all Languages in UTF-8
+var stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語";
+  
+function checkRecursively(map1, map2) {
+  if (typeof map1 !== 'function' && typeof map2 !== 'function') {
+    if (!map1 || typeof map1 !== 'object') {
+        equal(map1, map2);
+    } else {
+      for (var key in map1) {
+        checkRecursively(map1[key], map2[key]);
+      }
+    }
+  }
+}
+
+module("Base Types");
+
+  asyncTest("Void", function() {
+    expect( 1 );
+    client.testVoid(function(result) {
+      equal(result, undefined);
+      QUnit.start();
+    });
+  });
+  
+  
+  asyncTest("String", function() {
+    expect( 3 );
+    QUnit.stop(2);
+    client.testString('', function(result){
+       equal(result, '');
+       QUnit.start();
+    });
+    client.testString(stringTest, function(result){
+       equal(result, stringTest);
+       QUnit.start();
+    });
+
+    var specialCharacters = 'quote: \" backslash:' +
+          ' forwardslash-escaped: \/ ' +
+          ' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
+          ' now-all-of-them-together: "\\\/\b\n\r\t' +
+          ' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><';
+    client.testString(specialCharacters, function(result){
+       equal(result, specialCharacters);
+       QUnit.start();
+    });
+  });
+  asyncTest("Double", function() {
+    expect( 4 );
+    QUnit.stop(3);
+    client.testDouble(0, function(result){
+       equal(result, 0);
+       QUnit.start();
+    });
+    client.testDouble(-1, function(result){
+       equal(result, -1);
+       QUnit.start();
+    });
+    client.testDouble(3.14, function(result){
+       equal(result, 3.14);
+       QUnit.start();
+    });
+    client.testDouble(Math.pow(2,60), function(result){
+       equal(result, Math.pow(2,60));
+       QUnit.start();
+    });
+  });
+  asyncTest("Byte", function() {
+    expect( 2 );
+    QUnit.stop();
+    client.testByte(0, function(result) {
+       equal(result, 0);
+       QUnit.start();
+    });
+    client.testByte(0x01, function(result) {
+       equal(result, 0x01);
+       QUnit.start();
+    });
+  });
+  asyncTest("I32", function() {
+    expect( 3 );
+    QUnit.stop(2);
+    client.testI32(0, function(result){
+       equal(result, 0);
+       QUnit.start();
+    });
+    client.testI32(Math.pow(2,30), function(result){
+       equal(result, Math.pow(2,30));
+       QUnit.start();
+    });
+    client.testI32(-Math.pow(2,30), function(result){
+       equal(result, -Math.pow(2,30));
+       QUnit.start();
+    });
+  });
+  asyncTest("I64", function() {
+    expect( 3 );
+    QUnit.stop(2);
+    client.testI64(0, function(result){
+       equal(result, 0);
+       QUnit.start();
+    });
+    //This is usually 2^60 but JS cannot represent anything over 2^52 accurately
+    client.testI64(Math.pow(2,52), function(result){
+       equal(result, Math.pow(2,52));
+       QUnit.start();
+    });
+    client.testI64(-Math.pow(2,52), function(result){
+       equal(result, -Math.pow(2,52));
+       QUnit.start();
+    });
+  });
+  
+
+  
+
+module("Structured Types");
+
+  asyncTest("Struct", function() {
+    expect( 5 );
+    var structTestInput = new ThriftTest.Xtruct();
+    structTestInput.string_thing = 'worked';
+    structTestInput.byte_thing = 0x01;
+    structTestInput.i32_thing = Math.pow(2,30);
+    //This is usually 2^60 but JS cannot represent anything over 2^52 accurately
+    structTestInput.i64_thing = Math.pow(2,52);
+
+    client.testStruct(structTestInput, function(result){
+      equal(result.string_thing, structTestInput.string_thing);
+      equal(result.byte_thing, structTestInput.byte_thing);
+      equal(result.i32_thing, structTestInput.i32_thing);
+      equal(result.i64_thing, structTestInput.i64_thing);
+      equal(JSON.stringify(result), JSON.stringify(structTestInput));
+      QUnit.start();      
+    });
+  });
+
+  asyncTest("Nest", function() {
+    expect( 7 );
+    var xtrTestInput = new ThriftTest.Xtruct();
+    xtrTestInput.string_thing = 'worked';
+    xtrTestInput.byte_thing = 0x01;
+    xtrTestInput.i32_thing = Math.pow(2,30);
+    //This is usually 2^60 but JS cannot represent anything over 2^52 accurately
+    xtrTestInput.i64_thing = Math.pow(2,52);
+    
+    var nestTestInput = new ThriftTest.Xtruct2();
+    nestTestInput.byte_thing = 0x02;
+    nestTestInput.struct_thing = xtrTestInput;
+    nestTestInput.i32_thing = Math.pow(2,15);
+    
+    client.testNest(nestTestInput, function(result){
+      equal(result.byte_thing, nestTestInput.byte_thing);
+      equal(result.struct_thing.string_thing, nestTestInput.struct_thing.string_thing);
+      equal(result.struct_thing.byte_thing, nestTestInput.struct_thing.byte_thing);
+      equal(result.struct_thing.i32_thing, nestTestInput.struct_thing.i32_thing);
+      equal(result.struct_thing.i64_thing, nestTestInput.struct_thing.i64_thing);
+      equal(result.i32_thing, nestTestInput.i32_thing);  
+      equal(JSON.stringify(result), JSON.stringify(nestTestInput));
+      QUnit.start();      
+    });
+  });
+
+  asyncTest("Map", function() {
+    expect( 3 );
+    var mapTestInput = {7:77, 8:88, 9:99};
+
+    client.testMap(mapTestInput, function(result){
+      for (var key in result) {
+        equal(result[key], mapTestInput[key]);
+      }
+      QUnit.start();  
+    });
+  });
+
+  asyncTest("StringMap", function() {
+    expect( 6 );
+    var mapTestInput = {
+      "a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
+      "longValue":stringTest, stringTest:"long key"
+    };
+
+    client.testStringMap(mapTestInput, function(result){
+      for (var key in result) {
+        equal(result[key], mapTestInput[key]);
+      }
+      QUnit.start();
+    });
+  });
+
+  asyncTest("Set", function() {
+    expect( 1 );
+    var setTestInput = [1,2,3];
+    client.testSet(setTestInput, function(result){
+      ok(result, setTestInput);
+      QUnit.start();
+    });
+  });
+
+  asyncTest("List", function() {
+    expect( 1 );
+    var listTestInput = [1,2,3];
+    client.testList(listTestInput, function(result){
+      ok(result, listTestInput);
+      QUnit.start();
+    });
+  });
+
+  asyncTest("Enum", function() {
+    expect( 1 );
+    client.testEnum(ThriftTest.Numberz.ONE, function(result){
+      equal(result, ThriftTest.Numberz.ONE);
+      QUnit.start();
+    });
+  });
+
+  asyncTest("TypeDef", function() {
+    expect( 1 );
+    client.testTypedef(69, function(result){
+      equal(result, 69);
+      QUnit.start();
+    });
+  });
+
+
+module("deeper!");
+
+  asyncTest("MapMap", function() {
+    expect( 16 );
+    var mapMapTestExpectedResult = {
+      "4":{"1":1,"2":2,"3":3,"4":4},
+      "-4":{"-4":-4, "-3":-3, "-2":-2, "-1":-1}
+    };
+
+    client.testMapMap(1, function(result){
+      for (var key in result) {
+        for (var key2 in result[key]) {
+          equal(result[key][key2], mapMapTestExpectedResult[key][key2]);
+        }
+      }
+      checkRecursively(result, mapMapTestExpectedResult);
+      QUnit.start();
+    });
+  });
+
+
+module("Exception");
+
+  asyncTest("Xception", function() {
+    expect(2);
+    client.testException("Xception", function(e){
+      equal(e.errorCode, 1001);
+      equal(e.message, "Xception");
+      QUnit.start();
+    });
+  });
+
+  asyncTest("no Exception", 0, function() {
+    expect( 1 );
+    client.testException("no Exception", function(e){
+      ok(!e);
+      QUnit.start();
+    });
+  });
+
+module("Insanity");
+
+  asyncTest("testInsanity", function() {
+    expect( 24 );
+    var insanity = {
+      "1":{
+        "2":{
+          "userMap":{ "5":5, "8":8 },
+          "xtructs":[{
+              "string_thing":"Goodbye4",
+              "byte_thing":4,
+              "i32_thing":4,
+              "i64_thing":4
+            },
+            {
+              "string_thing":"Hello2",
+              "byte_thing":2,
+              "i32_thing":2,
+              "i64_thing":2
+            }
+          ]
+        },
+        "3":{
+          "userMap":{ "5":5, "8":8 },
+          "xtructs":[{
+              "string_thing":"Goodbye4",
+              "byte_thing":4,
+              "i32_thing":4,
+              "i64_thing":4
+            },
+            {
+              "string_thing":"Hello2",
+              "byte_thing":2,
+              "i32_thing":2,
+              "i64_thing":2
+            }
+          ]
+        }
+      },
+      "2":{ "6":{ "userMap":null, "xtructs":null } }
+    };
+    client.testInsanity(new ThriftTest.Insanity(), function(res){
+      ok(res, JSON.stringify(res));
+      ok(insanity, JSON.stringify(insanity));
+      checkRecursively(res, insanity);
+      QUnit.start();
+    });
+  });
+
+
diff --git a/lib/js/test/test-jq.js b/lib/js/test/test-jq.js
index ed658e4..64608fe 100644
--- a/lib/js/test/test-jq.js
+++ b/lib/js/test/test-jq.js
@@ -29,9 +29,6 @@
  * ++ test-nojq.js for "-gen js" only tests

  */

 

-var transport = new Thrift.Transport("/service");

-var protocol  = new Thrift.Protocol(transport);

-var client    = new ThriftTest.ThriftTestClient(protocol);

 

 //////////////////////////////////

 //jQuery asynchronous tests

diff --git a/lib/js/test/test-nojq.js b/lib/js/test/test-nojq.js
index f67ea62..19f9e61 100644
--- a/lib/js/test/test-nojq.js
+++ b/lib/js/test/test-nojq.js
@@ -29,9 +29,6 @@
  * ++ test-jq.js for "-gen js:jquery" only tests
  */
 
-var transport = new Thrift.Transport("/service");
-var protocol  = new Thrift.Protocol(transport);
-var client    = new ThriftTest.ThriftTestClient(protocol);
 
 //////////////////////////////////
 //Async exception tests
diff --git a/lib/js/test/test.html b/lib/js/test/test.html
index 8f9e7ee..91d1a97 100755
--- a/lib/js/test/test.html
+++ b/lib/js/test/test.html
@@ -27,13 +27,18 @@
   <script src="gen-js/ThriftTest.js"       type="text/javascript" charset="utf-8"></script>

 

   <!-- jQuery -->

-  <script type="text/javascript" src="build/js/lib/jquery-1.7.2.js" charset="utf-8"></script>

+  <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js" charset="utf-8"></script>

   

   <!-- QUnit Test framework-->

-  <script type="text/javascript" src="build/js/lib/qunit.js" charset="utf-8"></script>

-  <link rel="stylesheet" href="build/js/lib/qunit.css" type="text/css" media="screen" />

+  <script type="text/javascript" src="http://code.jquery.com/qunit/qunit-1.14.0.js" charset="utf-8"></script>

+  <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.14.0.css" type="text/css" media="screen" />

   

   <!-- the Test Suite-->

+  <script>

+    var transport = new Thrift.Transport("/service");

+    var protocol  = new Thrift.Protocol(transport);

+    var client    = new ThriftTest.ThriftTestClient(protocol);

+  </script>

   <script type="text/javascript" src="test.js" charset="utf-8"></script>

   <script type="text/javascript" src="test-jq.js" charset="utf-8"></script>

 </head>

diff --git a/lib/js/test/test_handler.js b/lib/js/test/test_handler.js
index 33c8941..17d22cf 100644
--- a/lib/js/test/test_handler.js
+++ b/lib/js/test/test_handler.js
@@ -21,7 +21,7 @@
 //  Apache Thrift test service.

 

 var ttypes = require('./gen-nodejs/ThriftTest_types');

-var TException = require('thrift/thrift').TException;

+var TException = require('../../nodejs/lib/thrift').TException;

 

 var ThriftTestHandler = exports.ThriftTestHandler = {

   testVoid: function(result) {

diff --git a/lib/js/test/testws.html b/lib/js/test/testws.html
new file mode 100644
index 0000000..15ee195
--- /dev/null
+++ b/lib/js/test/testws.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

+<!--

+  Licensed to the Apache Software Foundation (ASF) under one

+  or more contributor license agreements. See the NOTICE file

+  distributed with this work for additional information

+  regarding copyright ownership. The ASF licenses this file

+  to you under the Apache License, Version 2.0 (the

+  "License"); you may not use this file except in compliance

+  with the License. You may obtain a copy of the License at

+

+    http://www.apache.org/licenses/LICENSE-2.0

+

+  Unless required by applicable law or agreed to in writing,

+  software distributed under the License is distributed on an

+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+  KIND, either express or implied. See the License for the

+  specific language governing permissions and limitations

+  under the License.

+-->

+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

+<head>

+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

+  <title>Thrift Javascript Bindings: Unit Test</title>

+

+  <script src="build/js/thrift.js"         type="text/javascript" charset="utf-8"></script>

+  <script src="gen-js/ThriftTest_types.js" type="text/javascript" charset="utf-8"></script>

+  <script src="gen-js/ThriftTest.js"       type="text/javascript" charset="utf-8"></script>

+

+  <!-- jQuery -->

+  <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.2.js" charset="utf-8"></script>

+  

+  <!-- QUnit Test framework-->

+  <script type="text/javascript" src="https://code.jquery.com/qunit/qunit-1.14.0.js" charset="utf-8"></script>

+  <link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.14.0.css" type="text/css" media="screen" />

+  

+  <!-- the Test Suite-->

+  <script>

+    var loc = window.location;

+    var ws_uri = ((loc.protocol === "https:") ? "wss://" : "ws://") + 

+                   loc.hostname + ":" + loc.port + loc.pathname;

+    var transport = new Thrift.TWebSocketTransport(ws_uri);

+    var protocol  = new Thrift.Protocol(transport);

+    var client    = new ThriftTest.ThriftTestClient(protocol);

+    transport.open();

+  </script>

+  <script type="text/javascript" src="test-async.js" charset="utf-8"></script>

+</head>

+<body>

+  <h1 id="qunit-header">Thrift Javascript Bindings: Unit Test (<a href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob;f=test/ThriftTest.thrift;hb=HEAD">ThriftTest.thrift</a>)</h1>

+  <h2 id="qunit-banner"></h2>

+  <div id="qunit-testrunner-toolbar"></div> 

+  <h2 id="qunit-userAgent"></h2>

+  <ol id="qunit-tests"><li><!-- get valid xhtml strict--></li></ol>

+  <p>

+      <a href="http://validator.w3.org/check/referer"><img

+          src="http://www.w3.org/Icons/valid-xhtml10"

+          alt="Valid XHTML 1.0!" height="31" width="88" /></a>

+  </p>

+</body>

+</html>