diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/AFB.js | 22 | ||||
-rw-r--r-- | test/monitoring/AFB.js | 22 | ||||
-rw-r--r-- | test/monitoring/monitor-pastel.css | 2 | ||||
-rw-r--r-- | test/monitoring/monitor.html | 2 | ||||
-rw-r--r-- | test/monitoring/monitor.js | 2 |
5 files changed, 29 insertions, 21 deletions
diff --git a/test/AFB.js b/test/AFB.js index 59e68abc..ed2ffc2d 100644 --- a/test/AFB.js +++ b/test/AFB.js @@ -21,7 +21,7 @@ if (typeof base != "object") var initial = { base: base.base || "api", - token: base.token || initialtoken || "hello", + token: base.token || initialtoken || "HELLO", host: base.host || window.location.host, url: base.url || undefined }; @@ -105,8 +105,7 @@ var AFB_websocket; function onclose(event) { for (var id in this.pendings) { - var ferr = this.pendings[id].onerror; - ferr && ferr(null, this); + try { this.pendings[id][1](); } catch (x) {/*TODO?*/} } this.pendings = {}; this.onclose && this.onclose(); @@ -131,8 +130,7 @@ var AFB_websocket; if (id in pendings) { var p = pendings[id]; delete pendings[id]; - var f = p[offset]; - f(ans); + try { p[offset](ans); } catch (x) {/*TODO?*/} } } @@ -166,12 +164,18 @@ var AFB_websocket; this.onabort = function(){}; } - function call(method, request) { + function call(method, request, callid) { return new Promise((function(resolve, reject){ var id, arr; - do { - id = String(this.counter = 4095 & (this.counter + 1)); - } while (id in this.pendings); + if (callid) { + id = String(callid); + if (id in this.pendings) + throw new Error("pending callid("+id+") exists"); + } else { + do { + id = String(this.counter = 4095 & (this.counter + 1)); + } while (id in this.pendings); + } this.pendings[id] = [ resolve, reject ]; arr = [CALL, id, method, request ]; if (AFB_context.token) arr.push(AFB_context.token); diff --git a/test/monitoring/AFB.js b/test/monitoring/AFB.js index 59e68abc..ed2ffc2d 100644 --- a/test/monitoring/AFB.js +++ b/test/monitoring/AFB.js @@ -21,7 +21,7 @@ if (typeof base != "object") var initial = { base: base.base || "api", - token: base.token || initialtoken || "hello", + token: base.token || initialtoken || "HELLO", host: base.host || window.location.host, url: base.url || undefined }; @@ -105,8 +105,7 @@ var AFB_websocket; function onclose(event) { for (var id in this.pendings) { - var ferr = this.pendings[id].onerror; - ferr && ferr(null, this); + try { this.pendings[id][1](); } catch (x) {/*TODO?*/} } this.pendings = {}; this.onclose && this.onclose(); @@ -131,8 +130,7 @@ var AFB_websocket; if (id in pendings) { var p = pendings[id]; delete pendings[id]; - var f = p[offset]; - f(ans); + try { p[offset](ans); } catch (x) {/*TODO?*/} } } @@ -166,12 +164,18 @@ var AFB_websocket; this.onabort = function(){}; } - function call(method, request) { + function call(method, request, callid) { return new Promise((function(resolve, reject){ var id, arr; - do { - id = String(this.counter = 4095 & (this.counter + 1)); - } while (id in this.pendings); + if (callid) { + id = String(callid); + if (id in this.pendings) + throw new Error("pending callid("+id+") exists"); + } else { + do { + id = String(this.counter = 4095 & (this.counter + 1)); + } while (id in this.pendings); + } this.pendings[id] = [ resolve, reject ]; arr = [CALL, id, method, request ]; if (AFB_context.token) arr.push(AFB_context.token); diff --git a/test/monitoring/monitor-pastel.css b/test/monitoring/monitor-pastel.css index d5cf3f6f..839f574f 100644 --- a/test/monitoring/monitor-pastel.css +++ b/test/monitoring/monitor-pastel.css @@ -266,7 +266,7 @@ body { /*******************************************************************/ /* json format */ -.json.string { color: lightskyblue; } +.json.string { color: teal; } .json.number { color: darkorange; } .json.boolean { color: deepskyblue; } .json.null { color: magenta; } diff --git a/test/monitoring/monitor.html b/test/monitoring/monitor.html index 2c07c1ba..5a418879 100644 --- a/test/monitoring/monitor.html +++ b/test/monitoring/monitor.html @@ -57,7 +57,7 @@ <div id="params" class="clearfix"> <div>host: <input type="text" id="param-host" size="50" value="localhost"></input></div> <div>port: <input type="text" id="param-port" size="10" value="1234"></input></div> - <div>token: <input type="text" id="param-token" size="33" value="hello"></input></div> + <div>token: <input type="text" id="param-token" size="33" value="HELLO"></input></div> </div> <div class="-flex-fill -box-out"> <div id="trace-events" class="-box-in"> diff --git a/test/monitoring/monitor.js b/test/monitoring/monitor.js index 5b9dc0ea..3c64ab33 100644 --- a/test/monitoring/monitor.js +++ b/test/monitoring/monitor.js @@ -131,7 +131,7 @@ function init() { at("param-host").value = document.location.hostname; at("param-port").value = document.location.port; var args = new URLSearchParams(document.location.search.substring(1)); - at("param-token").value = args.get("x-afb-token") || args.get("token") || "hello"; + at("param-token").value = args.get("x-afb-token") || args.get("token") || "HELLO"; document.onbeforeunload = on_disconnect; |