Check-in [d73ab988ad]
Overview
Comment:More work Duktape-based chrome-alike environment
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d73ab988adc8175b6bc1e0253027a5b43a275b0d
User & Date: rkeene on 2019-06-12 19:39:48
Other Links: manifest | tags
Context
2019-06-12
19:40
Tcl-based interface to JS SSH Agent check-in: 7ef094be65 user: rkeene tags: trunk
19:39
More work Duktape-based chrome-alike environment check-in: d73ab988ad user: rkeene tags: trunk
19:38
Handle converting from buffers which cannot be converted to byte arrays check-in: af11332c35 user: rkeene tags: trunk
Changes

Modified build/tcl/chrome-emu.js from [cfc05731e7] to [37c439b24d].





1
















2
3
4
5
6
























































































7
8
9
10
11
12
13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21





22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







console = {};
console._formatArgs = function(argInfo) {
	var idx, outArray;
	var arg;

	idx = 0;
	outArray = [];
	for (idx = 0; idx < argInfo.length; idx++) {
		arg = argInfo[idx];
		if (typeof(arg) === 'string' || typeof(arg) === 'number') {
			outArray.push(arg);
		} else if (typeof(arg) === 'undefined') {
			outArray.push("<undefined>");
		} else if (arg === null) {
			outArray.push("<null>");
		} else {
			outArray.push(JSON.stringify(arg));
		}
	}
	return(outArray.join(' '));
}
console = {
	log: function() {
		/* XXX:TODO: Logging */
	}
}
console.log = function() {
	runtime.puts("CON> " + console._formatArgs(arguments));
}
console.error = function(message) {
	runtime.puts(runtime.stderr, "ERR> " + console._formatArgs(arguments));
	return;
}
console.debug = function(message) {
	runtime.puts(runtime.stderr, "DBG> " + console._formatArgs(arguments));
	return;
}

if (!Array.from) {
	Array.from = function(source) {
		var result, idx;
		result = new Array(source.length);
		for (idx = 0; idx < source.length; idx++) {
			result[idx] = source[idx];
		}
		return(result);
	}
}

if (!Array.prototype.slice) {
	Array.prototype.slice = function(start) {
		var result, idx, outIdx;
		result = [];
		outIdx = 0;
		for (idx = start; idx < this.length; idx++) {
			result[outIdx] = this[idx];
			outIdx++;
		}
		return(result);
	}
}

if (!String.prototype.padStart) {
	String.prototype.padStart = function(len, char) {
		if (this.length >= len) {
			return(this);
		}

		return((char + this).padStart(len, char))
	}
}

if (!RegExp.prototype.compile) {
	RegExp.prototype.compile = function() {
		return;
	};
}

if (!Uint8Array.prototype.forEach) {
	Uint8Array.prototype.forEach = function(callback) {
		var idx;
		for (idx = 0; idx < this.length; idx++) {
			callback(this[idx]);
		}
	}
}

if (!Uint8Array.prototype.map) {
	Uint8Array.prototype.map = function(callback) {
		var result, idx;
		result = [];

		for (idx = 0; idx < this.length; idx++) {
			result.push(callback(this[idx]));
		}

		return(result);
	}
}

navigator = {
	userAgent: ""
};

crypto = {
	subtle: {
		digest: function(hash, data) {
			var bufferData;
			bufferData = new Buffer(data);
			return(crypto.subtle.digest.internal(hash, bufferData));
		}
	}
};

chrome = {
	runtime: {
		connectCallbacks: [],
		onConnectExternal: {
			addListener: function(callback) {
				if (!callback) {
					return;
22
23
24
25
26
27
28

29






125
126
127
128
129
130
131
132

133
134
135
136
137
138







+
-
+
+
+
+
+
+
					return;
				}

				chrome.runtime.connectCallbacks.splice(idx, 1);
			}
		}
	}
};
}

chrome.runtime.externalConnect = function(data) {
	chrome.runtime.connectCallbacks.forEach(function(callback) {
		callback(data);
	});
};