Best JavaScript code snippet using wpt
dataview.js
Source:dataview.js
1// |reftest| skip-if(!xulRuntime.shell)2/*3 * Any copyright is dedicated to the Public Domain.4 * http://creativecommons.org/licenses/publicdomain/5 * Contributor: Tobias Schneider <schneider@jancona.com>6 */7//------------------------------------------------------------------------------8var BUGNUMBER = 575688;9var summary = 'DataView tests';10function test() {11 function die(message, uplevel) {12 var e = new Error(message);13 var frame = e.stack.split("\n")[uplevel];14 print(message + " at " + frame.split("@")[1]);15 print("Stack:\n" + e.stack);16 throw(e);17 }18 function checkThrow(fun, type) {19 var thrown = false;20 try {21 fun();22 } catch (x) {23 thrown = x;24 }25 if (!thrown) {26 die('no exception thrown, expected ' + type.name, 2);27 } else if (!(thrown instanceof type)) {28 die('expected ' + type.name + ', got ' + thrown, 2);29 }30 }31 function checkThrowTODO(fun, type) {32 var thrown = false;33 try {34 fun();35 } catch (x) {36 thrown = x;37 }38 if (!thrown) {39 print('(TODO) no exception thrown, expected ' + type.name);40 } else if (!(thrown instanceof type)) {41 print('(TODO) expected ' + type.name + ', got ' + thrown);42 } else {43 print('test unexpectedly passed: expected ' + type.name + ' exception');44 }45 }46 enterFunc ('test');47 printBugNumber(BUGNUMBER);48 printStatus(summary);49 // testConstructor50 buffer = (new Uint8Array([1, 2])).buffer;51 checkThrow(function () new DataView(buffer, 0, 3), RangeError);52 checkThrow(function () new DataView(buffer, 1, 2), RangeError);53 checkThrow(function () new DataView(buffer, 2, 1), RangeError);54 checkThrow(function () new DataView(buffer, 2147483649, 0), RangeError);55 checkThrow(function () new DataView(buffer, 0, 2147483649), RangeError);56 checkThrow(function() new DataView(), TypeError);57 checkThrow(function() new DataView(Object.create(new ArrayBuffer(5))), TypeError);58 // testGetMethods59 // testIntegerGets(start=0, length=16)60 var data1 = [0,1,2,3,0x64,0x65,0x66,0x67,0x80,0x81,0x82,0x83,252,253,254,255];61 var data1_r = data1.slice().reverse();62 var buffer1 = new Uint8Array(data1).buffer;63 var view1 = new DataView(buffer1, 0, 16);64 view = view1;65 assertEq(view.getInt8(0), 0);66 assertEq(view.getInt8(8), -128);67 assertEq(view.getInt8(15), -1);68 assertEq(view.getUint8(0), 0);69 assertEq(view.getUint8(8), 128);70 assertEq(view.getUint8(15), 255);71 // Little endian.72 assertEq(view.getInt16(0, true), 256);73 assertEq(view.getInt16(5, true), 0x6665);74 assertEq(view.getInt16(9, true), -32127);75 assertEq(view.getInt16(14, true), -2);76 // Big endian.77 assertEq(view.getInt16(0), 1);78 assertEq(view.getInt16(5), 0x6566);79 assertEq(view.getInt16(9), -32382);80 assertEq(view.getInt16(14), -257);81 // Little endian.82 assertEq(view.getUint16(0, true), 256);83 assertEq(view.getUint16(5, true), 0x6665);84 assertEq(view.getUint16(9, true), 0x8281);85 assertEq(view.getUint16(14, true), 0xfffe);86 // Big endian.87 assertEq(view.getUint16(0), 1);88 assertEq(view.getUint16(5), 0x6566);89 assertEq(view.getUint16(9), 0x8182);90 assertEq(view.getUint16(14), 0xfeff);91 // Little endian.92 assertEq(view.getInt32(0, true), 0x3020100);93 assertEq(view.getInt32(3, true), 0x66656403);94 assertEq(view.getInt32(6, true), -2122291354);95 assertEq(view.getInt32(9, true), -58490239);96 assertEq(view.getInt32(12, true), -66052);97 // Big endian.98 assertEq(view.getInt32(0), 0x10203);99 assertEq(view.getInt32(3), 0x3646566);100 assertEq(view.getInt32(6), 0x66678081);101 assertEq(view.getInt32(9), -2122152964);102 assertEq(view.getInt32(12), -50462977);103 // Little endian.104 assertEq(view.getUint32(0, true), 0x3020100);105 assertEq(view.getUint32(3, true), 0x66656403);106 assertEq(view.getUint32(6, true), 0x81806766);107 assertEq(view.getUint32(9, true), 0xfc838281);108 assertEq(view.getUint32(12, true), 0xfffefdfc);109 // Big endian.110 assertEq(view.getUint32(0), 0x10203);111 assertEq(view.getUint32(3), 0x3646566);112 assertEq(view.getUint32(6), 0x66678081);113 assertEq(view.getUint32(9), 0x818283fc);114 assertEq(view.getUint32(12), 0xfcfdfeff);115 // testFloatGets(start=0)116 // testFloatGet expected=10117 // Little endian118 var data2 = [0,0,32,65];119 var data2_r = data2.slice().reverse();120 var buffer2 = new Uint8Array(data2).buffer;121 view = new DataView(buffer2, 0, 4);122 assertEq(view.getFloat32(0, true), 10);123 var buffer2_pad3 = new Uint8Array(Array(3).concat(data2)).buffer;124 view = new DataView(buffer2_pad3, 0, 7);125 assertEq(view.getFloat32(3, true), 10);126 var buffer2_pad7 = new Uint8Array(Array(7).concat(data2)).buffer;127 view = new DataView(buffer2_pad7, 0, 11);128 assertEq(view.getFloat32(7, true), 10);129 var buffer2_pad10 = new Uint8Array(Array(10).concat(data2)).buffer;130 view = new DataView(buffer2_pad10, 0, 14);131 assertEq(view.getFloat32(10, true), 10);132 // Big endian.133 var buffer2_r = new Uint8Array(data2_r).buffer;134 view = new DataView(buffer2_r, 0, 4);135 assertEq(view.getFloat32(0, false), 10);136 var buffer2_r_pad3 = new Uint8Array(Array(3).concat(data2_r)).buffer;137 view = new DataView(buffer2_r_pad3, 0, 7);138 assertEq(view.getFloat32(3, false), 10);139 var buffer2_r_pad7 = new Uint8Array(Array(7).concat(data2_r)).buffer;140 view = new DataView(buffer2_r_pad7, 0, 11);141 assertEq(view.getFloat32(7, false), 10);142 var buffer2_r_pad10 = new Uint8Array(Array(10).concat(data2_r)).buffer;143 view = new DataView(buffer2_r_pad10, 0, 14);144 assertEq(view.getFloat32(10, false), 10);145 // testFloatGet expected=1.2300000190734863146 // Little endian147 var data3 = [164,112,157,63];148 var data3_r = data3.slice().reverse();149 var buffer3 = new Uint8Array(data3).buffer;150 view = new DataView(buffer3, 0, 4);151 assertEq(view.getFloat32(0, true), 1.2300000190734863);152 var buffer3_pad3 = new Uint8Array(Array(3).concat(data3)).buffer;153 view = new DataView(buffer3_pad3, 0, 7);154 assertEq(view.getFloat32(3, true), 1.2300000190734863);155 var buffer3_pad7 = new Uint8Array(Array(7).concat(data3)).buffer;156 view = new DataView(buffer3_pad7, 0, 11);157 assertEq(view.getFloat32(7, true), 1.2300000190734863);158 var buffer3_pad10 = new Uint8Array(Array(10).concat(data3)).buffer;159 view = new DataView(buffer3_pad10, 0, 14);160 assertEq(view.getFloat32(10, true), 1.2300000190734863);161 // Big endian.162 var buffer3_r = new Uint8Array(data3_r).buffer;163 view = new DataView(buffer3_r, 0, 4);164 assertEq(view.getFloat32(0, false), 1.2300000190734863);165 var buffer3_r_pad3 = new Uint8Array(Array(3).concat(data3_r)).buffer;166 view = new DataView(buffer3_r_pad3, 0, 7);167 assertEq(view.getFloat32(3, false), 1.2300000190734863);168 var buffer3_r_pad7 = new Uint8Array(Array(7).concat(data3_r)).buffer;169 view = new DataView(buffer3_r_pad7, 0, 11);170 assertEq(view.getFloat32(7, false), 1.2300000190734863);171 var buffer3_r_pad10 = new Uint8Array(Array(10).concat(data3_r)).buffer;172 view = new DataView(buffer3_r_pad10, 0, 14);173 assertEq(view.getFloat32(10, false), 1.2300000190734863);174 // testFloatGet expected=-45621.37109375175 // Little endian176 var data4 = [95,53,50,199];177 var data4_r = data4.slice().reverse();178 var buffer4 = new Uint8Array(data4).buffer;179 view = new DataView(buffer4, 0, 4);180 assertEq(view.getFloat32(0, true), -45621.37109375);181 var buffer4_pad3 = new Uint8Array(Array(3).concat(data4)).buffer;182 view = new DataView(buffer4_pad3, 0, 7);183 assertEq(view.getFloat32(3, true), -45621.37109375);184 var buffer4_pad7 = new Uint8Array(Array(7).concat(data4)).buffer;185 view = new DataView(buffer4_pad7, 0, 11);186 assertEq(view.getFloat32(7, true), -45621.37109375);187 var buffer4_pad10 = new Uint8Array(Array(10).concat(data4)).buffer;188 view = new DataView(buffer4_pad10, 0, 14);189 assertEq(view.getFloat32(10, true), -45621.37109375);190 // Big endian.191 var buffer4_r = new Uint8Array(data4_r).buffer;192 view = new DataView(buffer4_r, 0, 4);193 assertEq(view.getFloat32(0, false), -45621.37109375);194 var buffer4_r_pad3 = new Uint8Array(Array(3).concat(data4_r)).buffer;195 view = new DataView(buffer4_r_pad3, 0, 7);196 assertEq(view.getFloat32(3, false), -45621.37109375);197 var buffer4_r_pad7 = new Uint8Array(Array(7).concat(data4_r)).buffer;198 view = new DataView(buffer4_r_pad7, 0, 11);199 assertEq(view.getFloat32(7, false), -45621.37109375);200 var buffer4_r_pad10 = new Uint8Array(Array(10).concat(data4_r)).buffer;201 view = new DataView(buffer4_r_pad10, 0, 14);202 assertEq(view.getFloat32(10, false), -45621.37109375);203 // testFloatGet expected=NaN204 // Little endian205 var data5 = [255,255,255,127];206 var data5_r = data5.slice().reverse();207 var buffer5 = new Uint8Array(data5).buffer;208 view = new DataView(buffer5, 0, 4);209 assertEq(view.getFloat32(0, true), NaN);210 var buffer5_pad3 = new Uint8Array(Array(3).concat(data5)).buffer;211 view = new DataView(buffer5_pad3, 0, 7);212 assertEq(view.getFloat32(3, true), NaN);213 var buffer5_pad7 = new Uint8Array(Array(7).concat(data5)).buffer;214 view = new DataView(buffer5_pad7, 0, 11);215 assertEq(view.getFloat32(7, true), NaN);216 var buffer5_pad10 = new Uint8Array(Array(10).concat(data5)).buffer;217 view = new DataView(buffer5_pad10, 0, 14);218 assertEq(view.getFloat32(10, true), NaN);219 // Big endian.220 var buffer5_r = new Uint8Array(data5_r).buffer;221 view = new DataView(buffer5_r, 0, 4);222 assertEq(view.getFloat32(0, false), NaN);223 var buffer5_r_pad3 = new Uint8Array(Array(3).concat(data5_r)).buffer;224 view = new DataView(buffer5_r_pad3, 0, 7);225 assertEq(view.getFloat32(3, false), NaN);226 var buffer5_r_pad7 = new Uint8Array(Array(7).concat(data5_r)).buffer;227 view = new DataView(buffer5_r_pad7, 0, 11);228 assertEq(view.getFloat32(7, false), NaN);229 var buffer5_r_pad10 = new Uint8Array(Array(10).concat(data5_r)).buffer;230 view = new DataView(buffer5_r_pad10, 0, 14);231 assertEq(view.getFloat32(10, false), NaN);232 // testFloatGet expected=NaN233 // Little endian234 var data6 = [255,255,255,255];235 var data6_r = data6.slice().reverse();236 var buffer6 = new Uint8Array(data6).buffer;237 view = new DataView(buffer6, 0, 4);238 assertEq(view.getFloat32(0, true), NaN);239 var buffer6_pad3 = new Uint8Array(Array(3).concat(data6)).buffer;240 view = new DataView(buffer6_pad3, 0, 7);241 assertEq(view.getFloat32(3, true), NaN);242 var buffer6_pad7 = new Uint8Array(Array(7).concat(data6)).buffer;243 view = new DataView(buffer6_pad7, 0, 11);244 assertEq(view.getFloat32(7, true), NaN);245 var buffer6_pad10 = new Uint8Array(Array(10).concat(data6)).buffer;246 view = new DataView(buffer6_pad10, 0, 14);247 assertEq(view.getFloat32(10, true), NaN);248 // Big endian.249 var buffer6_r = new Uint8Array(data6_r).buffer;250 view = new DataView(buffer6_r, 0, 4);251 assertEq(view.getFloat32(0, false), NaN);252 var buffer6_r_pad3 = new Uint8Array(Array(3).concat(data6_r)).buffer;253 view = new DataView(buffer6_r_pad3, 0, 7);254 assertEq(view.getFloat32(3, false), NaN);255 var buffer6_r_pad7 = new Uint8Array(Array(7).concat(data6_r)).buffer;256 view = new DataView(buffer6_r_pad7, 0, 11);257 assertEq(view.getFloat32(7, false), NaN);258 var buffer6_r_pad10 = new Uint8Array(Array(10).concat(data6_r)).buffer;259 view = new DataView(buffer6_r_pad10, 0, 14);260 assertEq(view.getFloat32(10, false), NaN);261 // testFloatGet expected=10262 // Little endian263 var data7 = [0,0,0,0,0,0,36,64];264 var data7_r = data7.slice().reverse();265 var buffer7 = new Uint8Array(data7).buffer;266 view = new DataView(buffer7, 0, 8);267 assertEq(view.getFloat64(0, true), 10);268 var buffer7_pad3 = new Uint8Array(Array(3).concat(data7)).buffer;269 view = new DataView(buffer7_pad3, 0, 11);270 assertEq(view.getFloat64(3, true), 10);271 var buffer7_pad7 = new Uint8Array(Array(7).concat(data7)).buffer;272 view = new DataView(buffer7_pad7, 0, 15);273 assertEq(view.getFloat64(7, true), 10);274 var buffer7_pad10 = new Uint8Array(Array(10).concat(data7)).buffer;275 view = new DataView(buffer7_pad10, 0, 18);276 assertEq(view.getFloat64(10, true), 10);277 // Big endian.278 var buffer7_r = new Uint8Array(data7_r).buffer;279 view = new DataView(buffer7_r, 0, 8);280 assertEq(view.getFloat64(0, false), 10);281 var buffer7_r_pad3 = new Uint8Array(Array(3).concat(data7_r)).buffer;282 view = new DataView(buffer7_r_pad3, 0, 11);283 assertEq(view.getFloat64(3, false), 10);284 var buffer7_r_pad7 = new Uint8Array(Array(7).concat(data7_r)).buffer;285 view = new DataView(buffer7_r_pad7, 0, 15);286 assertEq(view.getFloat64(7, false), 10);287 var buffer7_r_pad10 = new Uint8Array(Array(10).concat(data7_r)).buffer;288 view = new DataView(buffer7_r_pad10, 0, 18);289 assertEq(view.getFloat64(10, false), 10);290 // testFloatGet expected=1.23291 // Little endian292 var data8 = [174,71,225,122,20,174,243,63];293 var data8_r = data8.slice().reverse();294 var buffer8 = new Uint8Array(data8).buffer;295 view = new DataView(buffer8, 0, 8);296 assertEq(view.getFloat64(0, true), 1.23);297 var buffer8_pad3 = new Uint8Array(Array(3).concat(data8)).buffer;298 view = new DataView(buffer8_pad3, 0, 11);299 assertEq(view.getFloat64(3, true), 1.23);300 var buffer8_pad7 = new Uint8Array(Array(7).concat(data8)).buffer;301 view = new DataView(buffer8_pad7, 0, 15);302 assertEq(view.getFloat64(7, true), 1.23);303 var buffer8_pad10 = new Uint8Array(Array(10).concat(data8)).buffer;304 view = new DataView(buffer8_pad10, 0, 18);305 assertEq(view.getFloat64(10, true), 1.23);306 // Big endian.307 var buffer8_r = new Uint8Array(data8_r).buffer;308 view = new DataView(buffer8_r, 0, 8);309 assertEq(view.getFloat64(0, false), 1.23);310 var buffer8_r_pad3 = new Uint8Array(Array(3).concat(data8_r)).buffer;311 view = new DataView(buffer8_r_pad3, 0, 11);312 assertEq(view.getFloat64(3, false), 1.23);313 var buffer8_r_pad7 = new Uint8Array(Array(7).concat(data8_r)).buffer;314 view = new DataView(buffer8_r_pad7, 0, 15);315 assertEq(view.getFloat64(7, false), 1.23);316 var buffer8_r_pad10 = new Uint8Array(Array(10).concat(data8_r)).buffer;317 view = new DataView(buffer8_r_pad10, 0, 18);318 assertEq(view.getFloat64(10, false), 1.23);319 // testFloatGet expected=-6213576.4839320 // Little endian321 var data9 = [181,55,248,30,242,179,87,193];322 var data9_r = data9.slice().reverse();323 var buffer9 = new Uint8Array(data9).buffer;324 view = new DataView(buffer9, 0, 8);325 assertEq(view.getFloat64(0, true), -6213576.4839);326 var buffer9_pad3 = new Uint8Array(Array(3).concat(data9)).buffer;327 view = new DataView(buffer9_pad3, 0, 11);328 assertEq(view.getFloat64(3, true), -6213576.4839);329 var buffer9_pad7 = new Uint8Array(Array(7).concat(data9)).buffer;330 view = new DataView(buffer9_pad7, 0, 15);331 assertEq(view.getFloat64(7, true), -6213576.4839);332 var buffer9_pad10 = new Uint8Array(Array(10).concat(data9)).buffer;333 view = new DataView(buffer9_pad10, 0, 18);334 assertEq(view.getFloat64(10, true), -6213576.4839);335 // Big endian.336 var buffer9_r = new Uint8Array(data9_r).buffer;337 view = new DataView(buffer9_r, 0, 8);338 assertEq(view.getFloat64(0, false), -6213576.4839);339 var buffer9_r_pad3 = new Uint8Array(Array(3).concat(data9_r)).buffer;340 view = new DataView(buffer9_r_pad3, 0, 11);341 assertEq(view.getFloat64(3, false), -6213576.4839);342 var buffer9_r_pad7 = new Uint8Array(Array(7).concat(data9_r)).buffer;343 view = new DataView(buffer9_r_pad7, 0, 15);344 assertEq(view.getFloat64(7, false), -6213576.4839);345 var buffer9_r_pad10 = new Uint8Array(Array(10).concat(data9_r)).buffer;346 view = new DataView(buffer9_r_pad10, 0, 18);347 assertEq(view.getFloat64(10, false), -6213576.4839);348 // testFloatGet expected=NaN349 // Little endian350 var data10 = [255,255,255,255,255,255,255,127];351 var data10_r = data10.slice().reverse();352 var buffer10 = new Uint8Array(data10).buffer;353 view = new DataView(buffer10, 0, 8);354 assertEq(view.getFloat64(0, true), NaN);355 var buffer10_pad3 = new Uint8Array(Array(3).concat(data10)).buffer;356 view = new DataView(buffer10_pad3, 0, 11);357 assertEq(view.getFloat64(3, true), NaN);358 var buffer10_pad7 = new Uint8Array(Array(7).concat(data10)).buffer;359 view = new DataView(buffer10_pad7, 0, 15);360 assertEq(view.getFloat64(7, true), NaN);361 var buffer10_pad10 = new Uint8Array(Array(10).concat(data10)).buffer;362 view = new DataView(buffer10_pad10, 0, 18);363 assertEq(view.getFloat64(10, true), NaN);364 // Big endian.365 var buffer10_r = new Uint8Array(data10_r).buffer;366 view = new DataView(buffer10_r, 0, 8);367 assertEq(view.getFloat64(0, false), NaN);368 var buffer10_r_pad3 = new Uint8Array(Array(3).concat(data10_r)).buffer;369 view = new DataView(buffer10_r_pad3, 0, 11);370 assertEq(view.getFloat64(3, false), NaN);371 var buffer10_r_pad7 = new Uint8Array(Array(7).concat(data10_r)).buffer;372 view = new DataView(buffer10_r_pad7, 0, 15);373 assertEq(view.getFloat64(7, false), NaN);374 var buffer10_r_pad10 = new Uint8Array(Array(10).concat(data10_r)).buffer;375 view = new DataView(buffer10_r_pad10, 0, 18);376 assertEq(view.getFloat64(10, false), NaN);377 // testFloatGet expected=NaN378 // Little endian379 var data11 = [255,255,255,255,255,255,255,255];380 var data11_r = data11.slice().reverse();381 var buffer11 = new Uint8Array(data11).buffer;382 view = new DataView(buffer11, 0, 8);383 assertEq(view.getFloat64(0, true), NaN);384 var buffer11_pad3 = new Uint8Array(Array(3).concat(data11)).buffer;385 view = new DataView(buffer11_pad3, 0, 11);386 assertEq(view.getFloat64(3, true), NaN);387 var buffer11_pad7 = new Uint8Array(Array(7).concat(data11)).buffer;388 view = new DataView(buffer11_pad7, 0, 15);389 assertEq(view.getFloat64(7, true), NaN);390 var buffer11_pad10 = new Uint8Array(Array(10).concat(data11)).buffer;391 view = new DataView(buffer11_pad10, 0, 18);392 assertEq(view.getFloat64(10, true), NaN);393 // Big endian.394 var buffer11_r = new Uint8Array(data11_r).buffer;395 view = new DataView(buffer11_r, 0, 8);396 assertEq(view.getFloat64(0, false), NaN);397 var buffer11_r_pad3 = new Uint8Array(Array(3).concat(data11_r)).buffer;398 view = new DataView(buffer11_r_pad3, 0, 11);399 assertEq(view.getFloat64(3, false), NaN);400 var buffer11_r_pad7 = new Uint8Array(Array(7).concat(data11_r)).buffer;401 view = new DataView(buffer11_r_pad7, 0, 15);402 assertEq(view.getFloat64(7, false), NaN);403 var buffer11_r_pad10 = new Uint8Array(Array(10).concat(data11_r)).buffer;404 view = new DataView(buffer11_r_pad10, 0, 18);405 assertEq(view.getFloat64(10, false), NaN);406 // testIntegerGets(start=3, length=2)407 var data12 = [31,32,33,0,1,2,3,100,101,102,103,128,129,130,131,252,253,254,255];408 var data12_r = data12.slice().reverse();409 var buffer12 = new Uint8Array(data12).buffer;410 view = new DataView(buffer12, 3, 2);411 assertEq(view.getInt8(0), 0);412 checkThrow(function () view.getInt8(8), RangeError);413 checkThrow(function () view.getInt8(15), RangeError);414 assertEq(view.getUint8(0), 0);415 checkThrow(function () view.getUint8(8), RangeError);416 checkThrow(function () view.getUint8(15), RangeError);417 // Little endian.418 assertEq(view.getInt16(0, true), 256);419 checkThrow(function () view.getInt16(5, true), RangeError);420 checkThrow(function () view.getInt16(9, true), RangeError);421 checkThrow(function () view.getInt16(14, true), RangeError);422 // Big endian.423 assertEq(view.getInt16(0), 1);424 checkThrow(function () view.getInt16(5), RangeError);425 checkThrow(function () view.getInt16(9), RangeError);426 checkThrow(function () view.getInt16(14), RangeError);427 // Little endian.428 assertEq(view.getUint16(0, true), 256);429 checkThrow(function () view.getUint16(5, true), RangeError);430 checkThrow(function () view.getUint16(9, true), RangeError);431 checkThrow(function () view.getUint16(14, true), RangeError);432 // Big endian.433 assertEq(view.getUint16(0), 1);434 checkThrow(function () view.getUint16(5), RangeError);435 checkThrow(function () view.getUint16(9), RangeError);436 checkThrow(function () view.getUint16(14), RangeError);437 // Little endian.438 checkThrow(function () view.getInt32(0, true), RangeError);439 checkThrow(function () view.getInt32(3, true), RangeError);440 checkThrow(function () view.getInt32(6, true), RangeError);441 checkThrow(function () view.getInt32(9, true), RangeError);442 checkThrow(function () view.getInt32(12, true), RangeError);443 // Big endian.444 checkThrow(function () view.getInt32(0), RangeError);445 checkThrow(function () view.getInt32(3), RangeError);446 checkThrow(function () view.getInt32(6), RangeError);447 checkThrow(function () view.getInt32(9), RangeError);448 checkThrow(function () view.getInt32(12), RangeError);449 // Little endian.450 checkThrow(function () view.getUint32(0, true), RangeError);451 checkThrow(function () view.getUint32(3, true), RangeError);452 checkThrow(function () view.getUint32(6, true), RangeError);453 checkThrow(function () view.getUint32(9, true), RangeError);454 checkThrow(function () view.getUint32(12, true), RangeError);455 // Big endian.456 checkThrow(function () view.getUint32(0), RangeError);457 checkThrow(function () view.getUint32(3), RangeError);458 checkThrow(function () view.getUint32(6), RangeError);459 checkThrow(function () view.getUint32(9), RangeError);460 checkThrow(function () view.getUint32(12), RangeError);461 // testFloatGets(start=3)462 // testFloatGet expected=10463 // Little endian464 view = new DataView(buffer2, 3, 1);465 checkThrow(function () view.getFloat32(0, true), RangeError);466 view = new DataView(buffer2_pad3, 3, 4);467 checkThrow(function () view.getFloat32(3, true), RangeError);468 view = new DataView(buffer2_pad7, 3, 8);469 checkThrow(function () view.getFloat32(7, true), RangeError);470 view = new DataView(buffer2_pad10, 3, 11);471 checkThrow(function () view.getFloat32(10, true), RangeError);472 // Big endian.473 view = new DataView(buffer2_r, 3, 1);474 checkThrow(function () view.getFloat32(0, false), RangeError);475 view = new DataView(buffer2_r_pad3, 3, 4);476 checkThrow(function () view.getFloat32(3, false), RangeError);477 view = new DataView(buffer2_r_pad7, 3, 8);478 checkThrow(function () view.getFloat32(7, false), RangeError);479 view = new DataView(buffer2_r_pad10, 3, 11);480 checkThrow(function () view.getFloat32(10, false), RangeError);481 // testFloatGet expected=1.2300000190734863482 // Little endian483 view = new DataView(buffer3, 3, 1);484 checkThrow(function () view.getFloat32(0, true), RangeError);485 view = new DataView(buffer3_pad3, 3, 4);486 checkThrow(function () view.getFloat32(3, true), RangeError);487 view = new DataView(buffer3_pad7, 3, 8);488 checkThrow(function () view.getFloat32(7, true), RangeError);489 view = new DataView(buffer3_pad10, 3, 11);490 checkThrow(function () view.getFloat32(10, true), RangeError);491 // Big endian.492 view = new DataView(buffer3_r, 3, 1);493 checkThrow(function () view.getFloat32(0, false), RangeError);494 view = new DataView(buffer3_r_pad3, 3, 4);495 checkThrow(function () view.getFloat32(3, false), RangeError);496 view = new DataView(buffer3_r_pad7, 3, 8);497 checkThrow(function () view.getFloat32(7, false), RangeError);498 view = new DataView(buffer3_r_pad10, 3, 11);499 checkThrow(function () view.getFloat32(10, false), RangeError);500 // testFloatGet expected=-45621.37109375501 // Little endian502 view = new DataView(buffer4, 3, 1);503 checkThrow(function () view.getFloat32(0, true), RangeError);504 view = new DataView(buffer4_pad3, 3, 4);505 checkThrow(function () view.getFloat32(3, true), RangeError);506 view = new DataView(buffer4_pad7, 3, 8);507 checkThrow(function () view.getFloat32(7, true), RangeError);508 view = new DataView(buffer4_pad10, 3, 11);509 checkThrow(function () view.getFloat32(10, true), RangeError);510 // Big endian.511 view = new DataView(buffer4_r, 3, 1);512 checkThrow(function () view.getFloat32(0, false), RangeError);513 view = new DataView(buffer4_r_pad3, 3, 4);514 checkThrow(function () view.getFloat32(3, false), RangeError);515 view = new DataView(buffer4_r_pad7, 3, 8);516 checkThrow(function () view.getFloat32(7, false), RangeError);517 view = new DataView(buffer4_r_pad10, 3, 11);518 checkThrow(function () view.getFloat32(10, false), RangeError);519 // testFloatGet expected=NaN520 // Little endian521 view = new DataView(buffer5, 3, 1);522 checkThrow(function () view.getFloat32(0, true), RangeError);523 view = new DataView(buffer5_pad3, 3, 4);524 checkThrow(function () view.getFloat32(3, true), RangeError);525 view = new DataView(buffer5_pad7, 3, 8);526 checkThrow(function () view.getFloat32(7, true), RangeError);527 view = new DataView(buffer5_pad10, 3, 11);528 checkThrow(function () view.getFloat32(10, true), RangeError);529 // Big endian.530 view = new DataView(buffer5_r, 3, 1);531 checkThrow(function () view.getFloat32(0, false), RangeError);532 view = new DataView(buffer5_r_pad3, 3, 4);533 checkThrow(function () view.getFloat32(3, false), RangeError);534 view = new DataView(buffer5_r_pad7, 3, 8);535 checkThrow(function () view.getFloat32(7, false), RangeError);536 view = new DataView(buffer5_r_pad10, 3, 11);537 checkThrow(function () view.getFloat32(10, false), RangeError);538 // testFloatGet expected=NaN539 // Little endian540 view = new DataView(buffer6, 3, 1);541 checkThrow(function () view.getFloat32(0, true), RangeError);542 view = new DataView(buffer6_pad3, 3, 4);543 checkThrow(function () view.getFloat32(3, true), RangeError);544 view = new DataView(buffer6_pad7, 3, 8);545 checkThrow(function () view.getFloat32(7, true), RangeError);546 view = new DataView(buffer6_pad10, 3, 11);547 checkThrow(function () view.getFloat32(10, true), RangeError);548 // Big endian.549 view = new DataView(buffer6_r, 3, 1);550 checkThrow(function () view.getFloat32(0, false), RangeError);551 view = new DataView(buffer6_r_pad3, 3, 4);552 checkThrow(function () view.getFloat32(3, false), RangeError);553 view = new DataView(buffer6_r_pad7, 3, 8);554 checkThrow(function () view.getFloat32(7, false), RangeError);555 view = new DataView(buffer6_r_pad10, 3, 11);556 checkThrow(function () view.getFloat32(10, false), RangeError);557 // testFloatGet expected=10558 // Little endian559 view = new DataView(buffer7, 3, 5);560 checkThrow(function () view.getFloat64(0, true), RangeError);561 view = new DataView(buffer7_pad3, 3, 8);562 checkThrow(function () view.getFloat64(3, true), RangeError);563 view = new DataView(buffer7_pad7, 3, 12);564 checkThrow(function () view.getFloat64(7, true), RangeError);565 view = new DataView(buffer7_pad10, 3, 15);566 checkThrow(function () view.getFloat64(10, true), RangeError);567 // Big endian.568 view = new DataView(buffer7_r, 3, 5);569 checkThrow(function () view.getFloat64(0, false), RangeError);570 view = new DataView(buffer7_r_pad3, 3, 8);571 checkThrow(function () view.getFloat64(3, false), RangeError);572 view = new DataView(buffer7_r_pad7, 3, 12);573 checkThrow(function () view.getFloat64(7, false), RangeError);574 view = new DataView(buffer7_r_pad10, 3, 15);575 checkThrow(function () view.getFloat64(10, false), RangeError);576 // testFloatGet expected=1.23577 // Little endian578 view = new DataView(buffer8, 3, 5);579 checkThrow(function () view.getFloat64(0, true), RangeError);580 view = new DataView(buffer8_pad3, 3, 8);581 checkThrow(function () view.getFloat64(3, true), RangeError);582 view = new DataView(buffer8_pad7, 3, 12);583 checkThrow(function () view.getFloat64(7, true), RangeError);584 view = new DataView(buffer8_pad10, 3, 15);585 checkThrow(function () view.getFloat64(10, true), RangeError);586 // Big endian.587 view = new DataView(buffer8_r, 3, 5);588 checkThrow(function () view.getFloat64(0, false), RangeError);589 view = new DataView(buffer8_r_pad3, 3, 8);590 checkThrow(function () view.getFloat64(3, false), RangeError);591 view = new DataView(buffer8_r_pad7, 3, 12);592 checkThrow(function () view.getFloat64(7, false), RangeError);593 view = new DataView(buffer8_r_pad10, 3, 15);594 checkThrow(function () view.getFloat64(10, false), RangeError);595 // testFloatGet expected=-6213576.4839596 // Little endian597 view = new DataView(buffer9, 3, 5);598 checkThrow(function () view.getFloat64(0, true), RangeError);599 view = new DataView(buffer9_pad3, 3, 8);600 checkThrow(function () view.getFloat64(3, true), RangeError);601 view = new DataView(buffer9_pad7, 3, 12);602 checkThrow(function () view.getFloat64(7, true), RangeError);603 view = new DataView(buffer9_pad10, 3, 15);604 checkThrow(function () view.getFloat64(10, true), RangeError);605 // Big endian.606 view = new DataView(buffer9_r, 3, 5);607 checkThrow(function () view.getFloat64(0, false), RangeError);608 view = new DataView(buffer9_r_pad3, 3, 8);609 checkThrow(function () view.getFloat64(3, false), RangeError);610 view = new DataView(buffer9_r_pad7, 3, 12);611 checkThrow(function () view.getFloat64(7, false), RangeError);612 view = new DataView(buffer9_r_pad10, 3, 15);613 checkThrow(function () view.getFloat64(10, false), RangeError);614 // testFloatGet expected=NaN615 // Little endian616 view = new DataView(buffer10, 3, 5);617 checkThrow(function () view.getFloat64(0, true), RangeError);618 view = new DataView(buffer10_pad3, 3, 8);619 checkThrow(function () view.getFloat64(3, true), RangeError);620 view = new DataView(buffer10_pad7, 3, 12);621 checkThrow(function () view.getFloat64(7, true), RangeError);622 view = new DataView(buffer10_pad10, 3, 15);623 checkThrow(function () view.getFloat64(10, true), RangeError);624 // Big endian.625 view = new DataView(buffer10_r, 3, 5);626 checkThrow(function () view.getFloat64(0, false), RangeError);627 view = new DataView(buffer10_r_pad3, 3, 8);628 checkThrow(function () view.getFloat64(3, false), RangeError);629 view = new DataView(buffer10_r_pad7, 3, 12);630 checkThrow(function () view.getFloat64(7, false), RangeError);631 view = new DataView(buffer10_r_pad10, 3, 15);632 checkThrow(function () view.getFloat64(10, false), RangeError);633 // testFloatGet expected=NaN634 // Little endian635 view = new DataView(buffer11, 3, 5);636 checkThrow(function () view.getFloat64(0, true), RangeError);637 view = new DataView(buffer11_pad3, 3, 8);638 checkThrow(function () view.getFloat64(3, true), RangeError);639 view = new DataView(buffer11_pad7, 3, 12);640 checkThrow(function () view.getFloat64(7, true), RangeError);641 view = new DataView(buffer11_pad10, 3, 15);642 checkThrow(function () view.getFloat64(10, true), RangeError);643 // Big endian.644 view = new DataView(buffer11_r, 3, 5);645 checkThrow(function () view.getFloat64(0, false), RangeError);646 view = new DataView(buffer11_r_pad3, 3, 8);647 checkThrow(function () view.getFloat64(3, false), RangeError);648 view = new DataView(buffer11_r_pad7, 3, 12);649 checkThrow(function () view.getFloat64(7, false), RangeError);650 view = new DataView(buffer11_r_pad10, 3, 15);651 checkThrow(function () view.getFloat64(10, false), RangeError);652 // testGetNegativeIndexes653 view = new DataView(buffer1, 0, 16);654 checkThrow(function () view.getInt8(-1), RangeError);655 checkThrow(function () view.getInt8(-2), RangeError);656 checkThrow(function () view.getUint8(-1), RangeError);657 checkThrow(function () view.getUint8(-2), RangeError);658 checkThrow(function () view.getInt16(-1), RangeError);659 checkThrow(function () view.getInt16(-2), RangeError);660 checkThrow(function () view.getInt16(-3), RangeError);661 checkThrow(function () view.getUint16(-1), RangeError);662 checkThrow(function () view.getUint16(-2), RangeError);663 checkThrow(function () view.getUint16(-3), RangeError);664 checkThrow(function () view.getInt32(-1), RangeError);665 checkThrow(function () view.getInt32(-3), RangeError);666 checkThrow(function () view.getInt32(-5), RangeError);667 checkThrow(function () view.getUint32(-1), RangeError);668 checkThrow(function () view.getUint32(-3), RangeError);669 checkThrow(function () view.getUint32(-5), RangeError);670 view = new DataView(buffer7, 0, 8);671 checkThrow(function () view.getFloat32(-1), RangeError);672 checkThrow(function () view.getFloat32(-3), RangeError);673 checkThrow(function () view.getFloat32(-5), RangeError);674 checkThrow(function () view.getFloat64(-1), RangeError);675 checkThrow(function () view.getFloat64(-5), RangeError);676 checkThrow(function () view.getFloat64(-9), RangeError);677 // Too large for signed 32 bit integer index678 checkThrow(function () view.getInt8(2147483648), RangeError);679 checkThrow(function () view.getInt8(2147483649), RangeError);680 checkThrow(function () view.getUint8(2147483648), RangeError);681 checkThrow(function () view.getUint8(2147483649), RangeError);682 checkThrow(function () view.getInt16(2147483648), RangeError);683 checkThrow(function () view.getInt16(2147483649), RangeError);684 checkThrow(function () view.getUint16(2147483648), RangeError);685 checkThrow(function () view.getUint16(2147483649), RangeError);686 checkThrow(function () view.getInt32(2147483648), RangeError);687 checkThrow(function () view.getInt32(2147483649), RangeError);688 checkThrow(function () view.getUint32(2147483648), RangeError);689 checkThrow(function () view.getUint32(2147483649), RangeError);690 checkThrow(function () view.getFloat32(2147483648), RangeError);691 checkThrow(function () view.getFloat32(2147483649), RangeError);692 checkThrow(function () view.getFloat64(2147483648), RangeError);693 checkThrow(function () view.getFloat64(2147483649), RangeError);694 // Test for wrong arguments passed to get methods695 //696 // See http://www.w3.org/TR/WebIDL/#es-operations and the step saying "If entry is null, throw a TypeError."697 checkThrow(function () view.getInt8(), TypeError);698 checkThrow(function () view.getUint8(), TypeError);699 checkThrow(function () view.getInt16(), TypeError);700 checkThrow(function () view.getUint16(), TypeError);701 checkThrow(function () view.getInt32(), TypeError);702 checkThrow(function () view.getUint32(), TypeError);703 checkThrow(function () view.getFloat32(), TypeError);704 checkThrow(function () view.getFloat64(), TypeError);705 // Test for wrong type of |this|706 checkThrow(function () view.getInt8.apply("dead", [0]), TypeError);707 checkThrow(function () view.getUint8.apply("puppies", [0]), TypeError);708 checkThrow(function () view.getInt16.apply("aren", [0]), TypeError);709 checkThrow(function () view.getUint16.apply("t", [0]), TypeError);710 checkThrow(function () view.getInt32.apply("much", [0]), TypeError);711 checkThrow(function () view.getUint32.apply("fun", [0]), TypeError);712 checkThrow(function () view.getFloat32.apply("(in", [0]), TypeError);713 checkThrow(function () view.getFloat64.apply("bed)", [0]), TypeError);714 checkThrow(function () view.setInt8.apply("dead", [0, 0]), TypeError);715 checkThrow(function () view.setUint8.apply("puppies", [0, 0]), TypeError);716 checkThrow(function () view.setInt16.apply("aren", [0, 0]), TypeError);717 checkThrow(function () view.setUint16.apply("t", [0, 0]), TypeError);718 checkThrow(function () view.setInt32.apply("much", [0, 0]), TypeError);719 checkThrow(function () view.setUint32.apply("fun", [0, 0]), TypeError);720 checkThrow(function () view.setFloat32.apply("(in", [0, 0]), TypeError);721 checkThrow(function () view.setFloat64.apply("bed)", [0, 0]), TypeError);722 // testSetMethods723 // Test for set methods that work724 // testIntegerSets(start=0, length=16)725 var data13 = [204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204];726 var data13_r = data13.slice().reverse();727 var buffer13 = new Uint8Array(data13).buffer;728 view = new DataView(buffer13, 0, 16);729 view.setInt8(0, 0);730 assertEq(view.getInt8(0), 0);731 view.setInt8(8, -128);732 assertEq(view.getInt8(8), -128);733 view.setInt8(15, -1);734 assertEq(view.getInt8(15), -1);735 view.setUint8(0, 0);736 assertEq(view.getUint8(0), 0);737 view.setUint8(8, 128);738 assertEq(view.getUint8(8), 128);739 view.setUint8(15, 255);740 assertEq(view.getUint8(15), 255);741 view.setInt16(0, 256, true);742 assertEq(view.getInt16(0, true), 256);743 view.setInt16(5, 26213, true);744 assertEq(view.getInt16(5, true), 26213);745 view.setInt16(9, -32127, true);746 assertEq(view.getInt16(9, true), -32127);747 view.setInt16(14, -2, true);748 assertEq(view.getInt16(14, true), -2);749 view.setInt16(0, 1);750 assertEq(view.getInt16(0), 1);751 view.setInt16(5, 25958);752 assertEq(view.getInt16(5), 25958);753 view.setInt16(9, -32382);754 assertEq(view.getInt16(9), -32382);755 view.setInt16(14, -257);756 assertEq(view.getInt16(14), -257);757 view.setUint16(0, 256, true);758 assertEq(view.getUint16(0, true), 256);759 view.setUint16(5, 26213, true);760 assertEq(view.getUint16(5, true), 26213);761 view.setUint16(9, 33409, true);762 assertEq(view.getUint16(9, true), 33409);763 view.setUint16(14, 65534, true);764 assertEq(view.getUint16(14, true), 65534);765 view.setUint16(0, 1);766 assertEq(view.getUint16(0), 1);767 view.setUint16(5, 25958);768 assertEq(view.getUint16(5), 25958);769 view.setUint16(9, 33154);770 assertEq(view.getUint16(9), 33154);771 view.setUint16(14, 65279);772 assertEq(view.getUint16(14), 65279);773 view.setInt32(0, 50462976, true);774 assertEq(view.getInt32(0, true), 50462976);775 view.setInt32(3, 1717920771, true);776 assertEq(view.getInt32(3, true), 1717920771);777 view.setInt32(6, -2122291354, true);778 assertEq(view.getInt32(6, true), -2122291354);779 view.setInt32(9, -58490239, true);780 assertEq(view.getInt32(9, true), -58490239);781 view.setInt32(12, -66052, true);782 assertEq(view.getInt32(12, true), -66052);783 view.setInt32(0, 66051);784 assertEq(view.getInt32(0), 66051);785 view.setInt32(3, 56911206);786 assertEq(view.getInt32(3), 56911206);787 view.setInt32(6, 1718059137);788 assertEq(view.getInt32(6), 1718059137);789 view.setInt32(9, -2122152964);790 assertEq(view.getInt32(9), -2122152964);791 view.setInt32(12, -50462977);792 assertEq(view.getInt32(12), -50462977);793 view.setUint32(0, 50462976, true);794 assertEq(view.getUint32(0, true), 50462976);795 view.setUint32(3, 1717920771, true);796 assertEq(view.getUint32(3, true), 1717920771);797 view.setUint32(6, 2172675942, true);798 assertEq(view.getUint32(6, true), 2172675942);799 view.setUint32(9, 4236477057, true);800 assertEq(view.getUint32(9, true), 4236477057);801 view.setUint32(12, 4294901244, true);802 assertEq(view.getUint32(12, true), 4294901244);803 view.setUint32(0, 66051);804 assertEq(view.getUint32(0), 66051);805 view.setUint32(3, 56911206);806 assertEq(view.getUint32(3), 56911206);807 view.setUint32(6, 1718059137);808 assertEq(view.getUint32(6), 1718059137);809 view.setUint32(9, 2172814332);810 assertEq(view.getUint32(9), 2172814332);811 view.setUint32(12, 4244504319);812 assertEq(view.getUint32(12), 4244504319);813 // testFloatSets(start=undefined)814 // testFloatSet expected=10815 // Little endian816 view = new DataView(buffer13, 0, 16);817 view.setFloat32(0, 10, true);818 assertEq(view.getFloat32(0, true), 10);819 var buffer13_pad3 = new Uint8Array(Array(3).concat(data13)).buffer;820 view = new DataView(buffer13_pad3, 0, 19);821 view.setFloat32(3, 10, true);822 assertEq(view.getFloat32(3, true), 10);823 var buffer13_pad7 = new Uint8Array(Array(7).concat(data13)).buffer;824 view = new DataView(buffer13_pad7, 0, 23);825 view.setFloat32(7, 10, true);826 assertEq(view.getFloat32(7, true), 10);827 var buffer13_pad10 = new Uint8Array(Array(10).concat(data13)).buffer;828 view = new DataView(buffer13_pad10, 0, 26);829 view.setFloat32(10, 10, true);830 assertEq(view.getFloat32(10, true), 10);831 // Big endian.832 var buffer13_r = new Uint8Array(data13_r).buffer;833 view = new DataView(buffer13_r, 0, 16);834 view.setFloat32(0, 10, false);835 assertEq(view.getFloat32(0, false), 10);836 var buffer13_r_pad3 = new Uint8Array(Array(3).concat(data13_r)).buffer;837 view = new DataView(buffer13_r_pad3, 0, 19);838 view.setFloat32(3, 10, false);839 assertEq(view.getFloat32(3, false), 10);840 var buffer13_r_pad7 = new Uint8Array(Array(7).concat(data13_r)).buffer;841 view = new DataView(buffer13_r_pad7, 0, 23);842 view.setFloat32(7, 10, false);843 assertEq(view.getFloat32(7, false), 10);844 var buffer13_r_pad10 = new Uint8Array(Array(10).concat(data13_r)).buffer;845 view = new DataView(buffer13_r_pad10, 0, 26);846 view.setFloat32(10, 10, false);847 assertEq(view.getFloat32(10, false), 10);848 // testFloatSet expected=1.2300000190734863849 // Little endian850 view = new DataView(buffer13, 0, 16);851 view.setFloat32(0, 1.2300000190734863, true);852 assertEq(view.getFloat32(0, true), 1.2300000190734863);853 view = new DataView(buffer13_pad3, 0, 19);854 view.setFloat32(3, 1.2300000190734863, true);855 assertEq(view.getFloat32(3, true), 1.2300000190734863);856 view = new DataView(buffer13_pad7, 0, 23);857 view.setFloat32(7, 1.2300000190734863, true);858 assertEq(view.getFloat32(7, true), 1.2300000190734863);859 view = new DataView(buffer13_pad10, 0, 26);860 view.setFloat32(10, 1.2300000190734863, true);861 assertEq(view.getFloat32(10, true), 1.2300000190734863);862 // Big endian.863 view = new DataView(buffer13_r, 0, 16);864 view.setFloat32(0, 1.2300000190734863, false);865 assertEq(view.getFloat32(0, false), 1.2300000190734863);866 view = new DataView(buffer13_r_pad3, 0, 19);867 view.setFloat32(3, 1.2300000190734863, false);868 assertEq(view.getFloat32(3, false), 1.2300000190734863);869 view = new DataView(buffer13_r_pad7, 0, 23);870 view.setFloat32(7, 1.2300000190734863, false);871 assertEq(view.getFloat32(7, false), 1.2300000190734863);872 view = new DataView(buffer13_r_pad10, 0, 26);873 view.setFloat32(10, 1.2300000190734863, false);874 assertEq(view.getFloat32(10, false), 1.2300000190734863);875 // testFloatSet expected=-45621.37109375876 // Little endian877 view = new DataView(buffer13, 0, 16);878 view.setFloat32(0, -45621.37109375, true);879 assertEq(view.getFloat32(0, true), -45621.37109375);880 view = new DataView(buffer13_pad3, 0, 19);881 view.setFloat32(3, -45621.37109375, true);882 assertEq(view.getFloat32(3, true), -45621.37109375);883 view = new DataView(buffer13_pad7, 0, 23);884 view.setFloat32(7, -45621.37109375, true);885 assertEq(view.getFloat32(7, true), -45621.37109375);886 view = new DataView(buffer13_pad10, 0, 26);887 view.setFloat32(10, -45621.37109375, true);888 assertEq(view.getFloat32(10, true), -45621.37109375);889 // Big endian.890 view = new DataView(buffer13_r, 0, 16);891 view.setFloat32(0, -45621.37109375, false);892 assertEq(view.getFloat32(0, false), -45621.37109375);893 view = new DataView(buffer13_r_pad3, 0, 19);894 view.setFloat32(3, -45621.37109375, false);895 assertEq(view.getFloat32(3, false), -45621.37109375);896 view = new DataView(buffer13_r_pad7, 0, 23);897 view.setFloat32(7, -45621.37109375, false);898 assertEq(view.getFloat32(7, false), -45621.37109375);899 view = new DataView(buffer13_r_pad10, 0, 26);900 view.setFloat32(10, -45621.37109375, false);901 assertEq(view.getFloat32(10, false), -45621.37109375);902 // testFloatSet expected=NaN903 // Little endian904 view = new DataView(buffer13, 0, 16);905 view.setFloat32(0, NaN, true);906 assertEq(view.getFloat32(0, true), NaN);907 view = new DataView(buffer13_pad3, 0, 19);908 view.setFloat32(3, NaN, true);909 assertEq(view.getFloat32(3, true), NaN);910 view = new DataView(buffer13_pad7, 0, 23);911 view.setFloat32(7, NaN, true);912 assertEq(view.getFloat32(7, true), NaN);913 view = new DataView(buffer13_pad10, 0, 26);914 view.setFloat32(10, NaN, true);915 assertEq(view.getFloat32(10, true), NaN);916 // Big endian.917 view = new DataView(buffer13_r, 0, 16);918 view.setFloat32(0, NaN, false);919 assertEq(view.getFloat32(0, false), NaN);920 view = new DataView(buffer13_r_pad3, 0, 19);921 view.setFloat32(3, NaN, false);922 assertEq(view.getFloat32(3, false), NaN);923 view = new DataView(buffer13_r_pad7, 0, 23);924 view.setFloat32(7, NaN, false);925 assertEq(view.getFloat32(7, false), NaN);926 view = new DataView(buffer13_r_pad10, 0, 26);927 view.setFloat32(10, NaN, false);928 assertEq(view.getFloat32(10, false), NaN);929 // testFloatSet expected=-NaN930 // Little endian931 view = new DataView(buffer13, 0, 16);932 view.setFloat32(0, -NaN, true);933 assertEq(view.getFloat32(0, true), -NaN);934 view = new DataView(buffer13_pad3, 0, 19);935 view.setFloat32(3, -NaN, true);936 assertEq(view.getFloat32(3, true), -NaN);937 view = new DataView(buffer13_pad7, 0, 23);938 view.setFloat32(7, -NaN, true);939 assertEq(view.getFloat32(7, true), -NaN);940 view = new DataView(buffer13_pad10, 0, 26);941 view.setFloat32(10, -NaN, true);942 assertEq(view.getFloat32(10, true), -NaN);943 // Big endian.944 view = new DataView(buffer13_r, 0, 16);945 view.setFloat32(0, -NaN, false);946 assertEq(view.getFloat32(0, false), -NaN);947 view = new DataView(buffer13_r_pad3, 0, 19);948 view.setFloat32(3, -NaN, false);949 assertEq(view.getFloat32(3, false), -NaN);950 view = new DataView(buffer13_r_pad7, 0, 23);951 view.setFloat32(7, -NaN, false);952 assertEq(view.getFloat32(7, false), -NaN);953 view = new DataView(buffer13_r_pad10, 0, 26);954 view.setFloat32(10, -NaN, false);955 assertEq(view.getFloat32(10, false), -NaN);956 // testFloatSet expected=10957 // Little endian958 view = new DataView(buffer13, 0, 16);959 view.setFloat64(0, 10, true);960 assertEq(view.getFloat64(0, true), 10);961 view = new DataView(buffer13_pad3, 0, 19);962 view.setFloat64(3, 10, true);963 assertEq(view.getFloat64(3, true), 10);964 view = new DataView(buffer13_pad7, 0, 23);965 view.setFloat64(7, 10, true);966 assertEq(view.getFloat64(7, true), 10);967 view = new DataView(buffer13_pad10, 0, 26);968 view.setFloat64(10, 10, true);969 assertEq(view.getFloat64(10, true), 10);970 // Big endian.971 view = new DataView(buffer13_r, 0, 16);972 view.setFloat64(0, 10, false);973 assertEq(view.getFloat64(0, false), 10);974 view = new DataView(buffer13_r_pad3, 0, 19);975 view.setFloat64(3, 10, false);976 assertEq(view.getFloat64(3, false), 10);977 view = new DataView(buffer13_r_pad7, 0, 23);978 view.setFloat64(7, 10, false);979 assertEq(view.getFloat64(7, false), 10);980 view = new DataView(buffer13_r_pad10, 0, 26);981 view.setFloat64(10, 10, false);982 assertEq(view.getFloat64(10, false), 10);983 // testFloatSet expected=1.23984 // Little endian985 view = new DataView(buffer13, 0, 16);986 view.setFloat64(0, 1.23, true);987 assertEq(view.getFloat64(0, true), 1.23);988 view = new DataView(buffer13_pad3, 0, 19);989 view.setFloat64(3, 1.23, true);990 assertEq(view.getFloat64(3, true), 1.23);991 view = new DataView(buffer13_pad7, 0, 23);992 view.setFloat64(7, 1.23, true);993 assertEq(view.getFloat64(7, true), 1.23);994 view = new DataView(buffer13_pad10, 0, 26);995 view.setFloat64(10, 1.23, true);996 assertEq(view.getFloat64(10, true), 1.23);997 // Big endian.998 view = new DataView(buffer13_r, 0, 16);999 view.setFloat64(0, 1.23, false);1000 assertEq(view.getFloat64(0, false), 1.23);1001 view = new DataView(buffer13_r_pad3, 0, 19);1002 view.setFloat64(3, 1.23, false);1003 assertEq(view.getFloat64(3, false), 1.23);1004 view = new DataView(buffer13_r_pad7, 0, 23);1005 view.setFloat64(7, 1.23, false);1006 assertEq(view.getFloat64(7, false), 1.23);1007 view = new DataView(buffer13_r_pad10, 0, 26);1008 view.setFloat64(10, 1.23, false);1009 assertEq(view.getFloat64(10, false), 1.23);1010 // testFloatSet expected=-6213576.48391011 // Little endian1012 view = new DataView(buffer13, 0, 16);1013 view.setFloat64(0, -6213576.4839, true);1014 assertEq(view.getFloat64(0, true), -6213576.4839);1015 view = new DataView(buffer13_pad3, 0, 19);1016 view.setFloat64(3, -6213576.4839, true);1017 assertEq(view.getFloat64(3, true), -6213576.4839);1018 view = new DataView(buffer13_pad7, 0, 23);1019 view.setFloat64(7, -6213576.4839, true);1020 assertEq(view.getFloat64(7, true), -6213576.4839);1021 view = new DataView(buffer13_pad10, 0, 26);1022 view.setFloat64(10, -6213576.4839, true);1023 assertEq(view.getFloat64(10, true), -6213576.4839);1024 // Big endian.1025 view = new DataView(buffer13_r, 0, 16);1026 view.setFloat64(0, -6213576.4839, false);1027 assertEq(view.getFloat64(0, false), -6213576.4839);1028 view = new DataView(buffer13_r_pad3, 0, 19);1029 view.setFloat64(3, -6213576.4839, false);1030 assertEq(view.getFloat64(3, false), -6213576.4839);1031 view = new DataView(buffer13_r_pad7, 0, 23);1032 view.setFloat64(7, -6213576.4839, false);1033 assertEq(view.getFloat64(7, false), -6213576.4839);1034 view = new DataView(buffer13_r_pad10, 0, 26);1035 view.setFloat64(10, -6213576.4839, false);1036 assertEq(view.getFloat64(10, false), -6213576.4839);1037 // testFloatSet expected=NaN1038 // Little endian1039 view = new DataView(buffer13, 0, 16);1040 view.setFloat64(0, NaN, true);1041 assertEq(view.getFloat64(0, true), NaN);1042 view = new DataView(buffer13_pad3, 0, 19);1043 view.setFloat64(3, NaN, true);1044 assertEq(view.getFloat64(3, true), NaN);1045 view = new DataView(buffer13_pad7, 0, 23);1046 view.setFloat64(7, NaN, true);1047 assertEq(view.getFloat64(7, true), NaN);1048 view = new DataView(buffer13_pad10, 0, 26);1049 view.setFloat64(10, NaN, true);1050 assertEq(view.getFloat64(10, true), NaN);1051 // Big endian.1052 view = new DataView(buffer13_r, 0, 16);1053 view.setFloat64(0, NaN, false);1054 assertEq(view.getFloat64(0, false), NaN);1055 view = new DataView(buffer13_r_pad3, 0, 19);1056 view.setFloat64(3, NaN, false);1057 assertEq(view.getFloat64(3, false), NaN);1058 view = new DataView(buffer13_r_pad7, 0, 23);1059 view.setFloat64(7, NaN, false);1060 assertEq(view.getFloat64(7, false), NaN);1061 view = new DataView(buffer13_r_pad10, 0, 26);1062 view.setFloat64(10, NaN, false);1063 assertEq(view.getFloat64(10, false), NaN);1064 // testFloatSet expected=-NaN1065 // Little endian1066 view = new DataView(buffer13, 0, 16);1067 view.setFloat64(0, -NaN, true);1068 assertEq(view.getFloat64(0, true), -NaN);1069 view = new DataView(buffer13_pad3, 0, 19);1070 view.setFloat64(3, -NaN, true);1071 assertEq(view.getFloat64(3, true), -NaN);1072 view = new DataView(buffer13_pad7, 0, 23);1073 view.setFloat64(7, -NaN, true);1074 assertEq(view.getFloat64(7, true), -NaN);1075 view = new DataView(buffer13_pad10, 0, 26);1076 view.setFloat64(10, -NaN, true);1077 assertEq(view.getFloat64(10, true), -NaN);1078 // Big endian.1079 view = new DataView(buffer13_r, 0, 16);1080 view.setFloat64(0, -NaN, false);1081 assertEq(view.getFloat64(0, false), -NaN);1082 view = new DataView(buffer13_r_pad3, 0, 19);1083 view.setFloat64(3, -NaN, false);1084 assertEq(view.getFloat64(3, false), -NaN);1085 view = new DataView(buffer13_r_pad7, 0, 23);1086 view.setFloat64(7, -NaN, false);1087 assertEq(view.getFloat64(7, false), -NaN);1088 view = new DataView(buffer13_r_pad10, 0, 26);1089 view.setFloat64(10, -NaN, false);1090 assertEq(view.getFloat64(10, false), -NaN);1091 // Test for set methods that might write beyond the range1092 // testIntegerSets(start=3, length=2)1093 view = new DataView(buffer13, 3, 2);1094 view.setInt8(0, 0);1095 assertEq(view.getInt8(0), 0);1096 checkThrow(function () view.setInt8(8, -128), RangeError);1097 checkThrow(function () view.setInt8(15, -1), RangeError);1098 view.setUint8(0, 0);1099 assertEq(view.getUint8(0), 0);1100 checkThrow(function () view.setUint8(8, 128), RangeError);1101 checkThrow(function () view.setUint8(15, 255), RangeError);1102 view.setInt16(0, 256, true);1103 assertEq(view.getInt16(0, true), 256);1104 checkThrow(function () view.setInt16(5, 26213, true), RangeError);1105 checkThrow(function () view.setInt16(9, -32127, true), RangeError);1106 checkThrow(function () view.setInt16(14, -2, true), RangeError);1107 view.setInt16(0, 1);1108 assertEq(view.getInt16(0), 1);1109 checkThrow(function () view.setInt16(5, 25958), RangeError);1110 checkThrow(function () view.setInt16(9, -32382), RangeError);1111 checkThrow(function () view.setInt16(14, -257), RangeError);1112 view.setUint16(0, 256, true);1113 assertEq(view.getUint16(0, true), 256);1114 checkThrow(function () view.setUint16(5, 26213, true), RangeError);1115 checkThrow(function () view.setUint16(9, 33409, true), RangeError);1116 checkThrow(function () view.setUint16(14, 65534, true), RangeError);1117 view.setUint16(0, 1);1118 assertEq(view.getUint16(0), 1);1119 checkThrow(function () view.setUint16(5, 25958), RangeError);1120 checkThrow(function () view.setUint16(9, 33154), RangeError);1121 checkThrow(function () view.setUint16(14, 65279), RangeError);1122 checkThrow(function () view.setInt32(0, 50462976, true), RangeError);1123 checkThrow(function () view.setInt32(3, 1717920771, true), RangeError);1124 checkThrow(function () view.setInt32(6, -2122291354, true), RangeError);1125 checkThrow(function () view.setInt32(9, -58490239, true), RangeError);1126 checkThrow(function () view.setInt32(12, -66052, true), RangeError);1127 checkThrow(function () view.setInt32(0, 66051), RangeError);1128 checkThrow(function () view.setInt32(3, 56911206), RangeError);1129 checkThrow(function () view.setInt32(6, 1718059137), RangeError);1130 checkThrow(function () view.setInt32(9, -2122152964), RangeError);1131 checkThrow(function () view.setInt32(12, -50462977), RangeError);1132 checkThrow(function () view.setUint32(0, 50462976, true), RangeError);1133 checkThrow(function () view.setUint32(3, 1717920771, true), RangeError);1134 checkThrow(function () view.setUint32(6, 2172675942, true), RangeError);1135 checkThrow(function () view.setUint32(9, 4236477057, true), RangeError);1136 checkThrow(function () view.setUint32(12, 4294901244, true), RangeError);1137 checkThrow(function () view.setUint32(0, 66051), RangeError);1138 checkThrow(function () view.setUint32(3, 56911206), RangeError);1139 checkThrow(function () view.setUint32(6, 1718059137), RangeError);1140 checkThrow(function () view.setUint32(9, 2172814332), RangeError);1141 checkThrow(function () view.setUint32(12, 4244504319), RangeError);1142 // testFloatSets(start=7)1143 // testFloatSet expected=101144 // Little endian1145 view = new DataView(buffer13, 7, 9);1146 view.setFloat32(0, 10, true);1147 assertEq(view.getFloat32(0, true), 10);1148 view = new DataView(buffer13_pad3, 7, 12);1149 view.setFloat32(3, 10, true);1150 assertEq(view.getFloat32(3, true), 10);1151 view = new DataView(buffer13_pad7, 7, 16);1152 view.setFloat32(7, 10, true);1153 assertEq(view.getFloat32(7, true), 10);1154 view = new DataView(buffer13_pad10, 7, 19);1155 view.setFloat32(10, 10, true);1156 assertEq(view.getFloat32(10, true), 10);1157 // Big endian.1158 view = new DataView(buffer13_r, 7, 9);1159 view.setFloat32(0, 10, false);1160 assertEq(view.getFloat32(0, false), 10);1161 view = new DataView(buffer13_r_pad3, 7, 12);1162 view.setFloat32(3, 10, false);1163 assertEq(view.getFloat32(3, false), 10);1164 view = new DataView(buffer13_r_pad7, 7, 16);1165 view.setFloat32(7, 10, false);1166 assertEq(view.getFloat32(7, false), 10);1167 view = new DataView(buffer13_r_pad10, 7, 19);1168 view.setFloat32(10, 10, false);1169 assertEq(view.getFloat32(10, false), 10);1170 // testFloatSet expected=1.23000001907348631171 // Little endian1172 view = new DataView(buffer13, 7, 9);1173 view.setFloat32(0, 1.2300000190734863, true);1174 assertEq(view.getFloat32(0, true), 1.2300000190734863);1175 view = new DataView(buffer13_pad3, 7, 12);1176 view.setFloat32(3, 1.2300000190734863, true);1177 assertEq(view.getFloat32(3, true), 1.2300000190734863);1178 view = new DataView(buffer13_pad7, 7, 16);1179 view.setFloat32(7, 1.2300000190734863, true);1180 assertEq(view.getFloat32(7, true), 1.2300000190734863);1181 view = new DataView(buffer13_pad10, 7, 19);1182 view.setFloat32(10, 1.2300000190734863, true);1183 assertEq(view.getFloat32(10, true), 1.2300000190734863);1184 // Big endian.1185 view = new DataView(buffer13_r, 7, 9);1186 view.setFloat32(0, 1.2300000190734863, false);1187 assertEq(view.getFloat32(0, false), 1.2300000190734863);1188 view = new DataView(buffer13_r_pad3, 7, 12);1189 view.setFloat32(3, 1.2300000190734863, false);1190 assertEq(view.getFloat32(3, false), 1.2300000190734863);1191 view = new DataView(buffer13_r_pad7, 7, 16);1192 view.setFloat32(7, 1.2300000190734863, false);1193 assertEq(view.getFloat32(7, false), 1.2300000190734863);1194 view = new DataView(buffer13_r_pad10, 7, 19);1195 view.setFloat32(10, 1.2300000190734863, false);1196 assertEq(view.getFloat32(10, false), 1.2300000190734863);1197 // testFloatSet expected=-45621.371093751198 // Little endian1199 view = new DataView(buffer13, 7, 9);1200 view.setFloat32(0, -45621.37109375, true);1201 assertEq(view.getFloat32(0, true), -45621.37109375);1202 view = new DataView(buffer13_pad3, 7, 12);1203 view.setFloat32(3, -45621.37109375, true);1204 assertEq(view.getFloat32(3, true), -45621.37109375);1205 view = new DataView(buffer13_pad7, 7, 16);1206 view.setFloat32(7, -45621.37109375, true);1207 assertEq(view.getFloat32(7, true), -45621.37109375);1208 view = new DataView(buffer13_pad10, 7, 19);1209 view.setFloat32(10, -45621.37109375, true);1210 assertEq(view.getFloat32(10, true), -45621.37109375);1211 // Big endian.1212 view = new DataView(buffer13_r, 7, 9);1213 view.setFloat32(0, -45621.37109375, false);1214 assertEq(view.getFloat32(0, false), -45621.37109375);1215 view = new DataView(buffer13_r_pad3, 7, 12);1216 view.setFloat32(3, -45621.37109375, false);1217 assertEq(view.getFloat32(3, false), -45621.37109375);1218 view = new DataView(buffer13_r_pad7, 7, 16);1219 view.setFloat32(7, -45621.37109375, false);1220 assertEq(view.getFloat32(7, false), -45621.37109375);1221 view = new DataView(buffer13_r_pad10, 7, 19);1222 view.setFloat32(10, -45621.37109375, false);1223 assertEq(view.getFloat32(10, false), -45621.37109375);1224 // testFloatSet expected=NaN1225 // Little endian1226 view = new DataView(buffer13, 7, 9);1227 view.setFloat32(0, NaN, true);1228 assertEq(view.getFloat32(0, true), NaN);1229 view = new DataView(buffer13_pad3, 7, 12);1230 view.setFloat32(3, NaN, true);1231 assertEq(view.getFloat32(3, true), NaN);1232 view = new DataView(buffer13_pad7, 7, 16);1233 view.setFloat32(7, NaN, true);1234 assertEq(view.getFloat32(7, true), NaN);1235 view = new DataView(buffer13_pad10, 7, 19);1236 view.setFloat32(10, NaN, true);1237 assertEq(view.getFloat32(10, true), NaN);1238 // Big endian.1239 view = new DataView(buffer13_r, 7, 9);1240 view.setFloat32(0, NaN, false);1241 assertEq(view.getFloat32(0, false), NaN);1242 view = new DataView(buffer13_r_pad3, 7, 12);1243 view.setFloat32(3, NaN, false);1244 assertEq(view.getFloat32(3, false), NaN);1245 view = new DataView(buffer13_r_pad7, 7, 16);1246 view.setFloat32(7, NaN, false);1247 assertEq(view.getFloat32(7, false), NaN);1248 view = new DataView(buffer13_r_pad10, 7, 19);1249 view.setFloat32(10, NaN, false);1250 assertEq(view.getFloat32(10, false), NaN);1251 // testFloatSet expected=-NaN1252 // Little endian1253 view = new DataView(buffer13, 7, 9);1254 view.setFloat32(0, -NaN, true);1255 assertEq(view.getFloat32(0, true), -NaN);1256 view = new DataView(buffer13_pad3, 7, 12);1257 view.setFloat32(3, -NaN, true);1258 assertEq(view.getFloat32(3, true), -NaN);1259 view = new DataView(buffer13_pad7, 7, 16);1260 view.setFloat32(7, -NaN, true);1261 assertEq(view.getFloat32(7, true), -NaN);1262 view = new DataView(buffer13_pad10, 7, 19);1263 view.setFloat32(10, -NaN, true);1264 assertEq(view.getFloat32(10, true), -NaN);1265 // Big endian.1266 view = new DataView(buffer13_r, 7, 9);1267 view.setFloat32(0, -NaN, false);1268 assertEq(view.getFloat32(0, false), -NaN);1269 view = new DataView(buffer13_r_pad3, 7, 12);1270 view.setFloat32(3, -NaN, false);1271 assertEq(view.getFloat32(3, false), -NaN);1272 view = new DataView(buffer13_r_pad7, 7, 16);1273 view.setFloat32(7, -NaN, false);1274 assertEq(view.getFloat32(7, false), -NaN);1275 view = new DataView(buffer13_r_pad10, 7, 19);1276 view.setFloat32(10, -NaN, false);1277 assertEq(view.getFloat32(10, false), -NaN);1278 // testFloatSet expected=101279 // Little endian1280 view = new DataView(buffer13, 7, 9);1281 view.setFloat64(0, 10, true);1282 assertEq(view.getFloat64(0, true), 10);1283 view = new DataView(buffer13_pad3, 7, 12);1284 view.setFloat64(3, 10, true);1285 assertEq(view.getFloat64(3, true), 10);1286 view = new DataView(buffer13_pad7, 7, 16);1287 view.setFloat64(7, 10, true);1288 assertEq(view.getFloat64(7, true), 10);1289 view = new DataView(buffer13_pad10, 7, 19);1290 view.setFloat64(10, 10, true);1291 assertEq(view.getFloat64(10, true), 10);1292 // Big endian.1293 view = new DataView(buffer13_r, 7, 9);1294 view.setFloat64(0, 10, false);1295 assertEq(view.getFloat64(0, false), 10);1296 view = new DataView(buffer13_r_pad3, 7, 12);1297 view.setFloat64(3, 10, false);1298 assertEq(view.getFloat64(3, false), 10);1299 view = new DataView(buffer13_r_pad7, 7, 16);1300 view.setFloat64(7, 10, false);1301 assertEq(view.getFloat64(7, false), 10);1302 view = new DataView(buffer13_r_pad10, 7, 19);1303 view.setFloat64(10, 10, false);1304 assertEq(view.getFloat64(10, false), 10);1305 // testFloatSet expected=1.231306 // Little endian1307 view = new DataView(buffer13, 7, 9);1308 view.setFloat64(0, 1.23, true);1309 assertEq(view.getFloat64(0, true), 1.23);1310 view = new DataView(buffer13_pad3, 7, 12);1311 view.setFloat64(3, 1.23, true);1312 assertEq(view.getFloat64(3, true), 1.23);1313 view = new DataView(buffer13_pad7, 7, 16);1314 view.setFloat64(7, 1.23, true);1315 assertEq(view.getFloat64(7, true), 1.23);1316 view = new DataView(buffer13_pad10, 7, 19);1317 view.setFloat64(10, 1.23, true);1318 assertEq(view.getFloat64(10, true), 1.23);1319 // Big endian.1320 view = new DataView(buffer13_r, 7, 9);1321 view.setFloat64(0, 1.23, false);1322 assertEq(view.getFloat64(0, false), 1.23);1323 view = new DataView(buffer13_r_pad3, 7, 12);1324 view.setFloat64(3, 1.23, false);1325 assertEq(view.getFloat64(3, false), 1.23);1326 view = new DataView(buffer13_r_pad7, 7, 16);1327 view.setFloat64(7, 1.23, false);1328 assertEq(view.getFloat64(7, false), 1.23);1329 view = new DataView(buffer13_r_pad10, 7, 19);1330 view.setFloat64(10, 1.23, false);1331 assertEq(view.getFloat64(10, false), 1.23);1332 // testFloatSet expected=-6213576.48391333 // Little endian1334 view = new DataView(buffer13, 7, 9);1335 view.setFloat64(0, -6213576.4839, true);1336 assertEq(view.getFloat64(0, true), -6213576.4839);1337 view = new DataView(buffer13_pad3, 7, 12);1338 view.setFloat64(3, -6213576.4839, true);1339 assertEq(view.getFloat64(3, true), -6213576.4839);1340 view = new DataView(buffer13_pad7, 7, 16);1341 view.setFloat64(7, -6213576.4839, true);1342 assertEq(view.getFloat64(7, true), -6213576.4839);1343 view = new DataView(buffer13_pad10, 7, 19);1344 view.setFloat64(10, -6213576.4839, true);1345 assertEq(view.getFloat64(10, true), -6213576.4839);1346 // Big endian.1347 view = new DataView(buffer13_r, 7, 9);1348 view.setFloat64(0, -6213576.4839, false);1349 assertEq(view.getFloat64(0, false), -6213576.4839);1350 view = new DataView(buffer13_r_pad3, 7, 12);1351 view.setFloat64(3, -6213576.4839, false);1352 assertEq(view.getFloat64(3, false), -6213576.4839);1353 view = new DataView(buffer13_r_pad7, 7, 16);1354 view.setFloat64(7, -6213576.4839, false);1355 assertEq(view.getFloat64(7, false), -6213576.4839);1356 view = new DataView(buffer13_r_pad10, 7, 19);1357 view.setFloat64(10, -6213576.4839, false);1358 assertEq(view.getFloat64(10, false), -6213576.4839);1359 // testFloatSet expected=NaN1360 // Little endian1361 view = new DataView(buffer13, 7, 9);1362 view.setFloat64(0, NaN, true);1363 assertEq(view.getFloat64(0, true), NaN);1364 view = new DataView(buffer13_pad3, 7, 12);1365 view.setFloat64(3, NaN, true);1366 assertEq(view.getFloat64(3, true), NaN);1367 view = new DataView(buffer13_pad7, 7, 16);1368 view.setFloat64(7, NaN, true);1369 assertEq(view.getFloat64(7, true), NaN);1370 view = new DataView(buffer13_pad10, 7, 19);1371 view.setFloat64(10, NaN, true);1372 assertEq(view.getFloat64(10, true), NaN);1373 // Big endian.1374 view = new DataView(buffer13_r, 7, 9);1375 view.setFloat64(0, NaN, false);1376 assertEq(view.getFloat64(0, false), NaN);1377 view = new DataView(buffer13_r_pad3, 7, 12);1378 view.setFloat64(3, NaN, false);1379 assertEq(view.getFloat64(3, false), NaN);1380 view = new DataView(buffer13_r_pad7, 7, 16);1381 view.setFloat64(7, NaN, false);1382 assertEq(view.getFloat64(7, false), NaN);1383 view = new DataView(buffer13_r_pad10, 7, 19);1384 view.setFloat64(10, NaN, false);1385 assertEq(view.getFloat64(10, false), NaN);1386 // testFloatSet expected=-NaN1387 // Little endian1388 view = new DataView(buffer13, 7, 9);1389 view.setFloat64(0, -NaN, true);1390 assertEq(view.getFloat64(0, true), -NaN);1391 view = new DataView(buffer13_pad3, 7, 12);1392 view.setFloat64(3, -NaN, true);1393 assertEq(view.getFloat64(3, true), -NaN);1394 view = new DataView(buffer13_pad7, 7, 16);1395 view.setFloat64(7, -NaN, true);1396 assertEq(view.getFloat64(7, true), -NaN);1397 view = new DataView(buffer13_pad10, 7, 19);1398 view.setFloat64(10, -NaN, true);1399 assertEq(view.getFloat64(10, true), -NaN);1400 // Big endian.1401 view = new DataView(buffer13_r, 7, 9);1402 view.setFloat64(0, -NaN, false);1403 assertEq(view.getFloat64(0, false), -NaN);1404 view = new DataView(buffer13_r_pad3, 7, 12);1405 view.setFloat64(3, -NaN, false);1406 assertEq(view.getFloat64(3, false), -NaN);1407 view = new DataView(buffer13_r_pad7, 7, 16);1408 view.setFloat64(7, -NaN, false);1409 assertEq(view.getFloat64(7, false), -NaN);1410 view = new DataView(buffer13_r_pad10, 7, 19);1411 view.setFloat64(10, -NaN, false);1412 assertEq(view.getFloat64(10, false), -NaN);1413 // Test for set methods that write to negative index1414 // testSetNegativeIndexes1415 view = new DataView(buffer1, 0, 16);1416 checkThrow(function () view.setInt8(-1, 0), RangeError);1417 checkThrow(function () view.setInt8(-2, 0), RangeError);1418 checkThrow(function () view.setUint8(-1, 0), RangeError);1419 checkThrow(function () view.setUint8(-2, 0), RangeError);1420 checkThrow(function () view.setInt16(-1, 0), RangeError);1421 checkThrow(function () view.setInt16(-2, 0), RangeError);1422 checkThrow(function () view.setInt16(-3, 0), RangeError);1423 checkThrow(function () view.setUint16(-1, 0), RangeError);1424 checkThrow(function () view.setUint16(-2, 0), RangeError);1425 checkThrow(function () view.setUint16(-3, 0), RangeError);1426 checkThrow(function () view.setInt32(-1, 0), RangeError);1427 checkThrow(function () view.setInt32(-3, 0), RangeError);1428 checkThrow(function () view.setInt32(-5, 0), RangeError);1429 checkThrow(function () view.setUint32(-1, 0), RangeError);1430 checkThrow(function () view.setUint32(-3, 0), RangeError);1431 checkThrow(function () view.setUint32(-5, 0), RangeError);1432 view = new DataView(buffer7, 0, 8);1433 checkThrow(function () view.setFloat32(-1, 0), RangeError);1434 checkThrow(function () view.setFloat32(-3, 0), RangeError);1435 checkThrow(function () view.setFloat32(-5, 0), RangeError);1436 checkThrow(function () view.setFloat64(-1, 0), RangeError);1437 checkThrow(function () view.setFloat64(-5, 0), RangeError);1438 checkThrow(function () view.setFloat64(-9, 0), RangeError);1439 // Too large for signed 32 bit integer index1440 checkThrow(function () view.setInt8(2147483649, 1), RangeError);1441 checkThrow(function () view.setUint8(2147483649, 1), RangeError);1442 checkThrow(function () view.setInt16(2147483649, 1), RangeError);1443 checkThrow(function () view.setUint16(2147483649, 1), RangeError);1444 checkThrow(function () view.setInt32(2147483649, 1), RangeError);1445 checkThrow(function () view.setUint32(2147483649, 1), RangeError);1446 checkThrow(function () view.setFloat32(2147483649, 1), RangeError);1447 checkThrow(function () view.setFloat64(2147483649, 1), RangeError);1448 // Test for wrong arguments passed to set methods1449 checkThrow(function () view.setInt8(), Error);1450 checkThrow(function () view.setUint8(), Error);1451 checkThrow(function () view.setInt16(), Error);1452 checkThrow(function () view.setUint16(), Error);1453 checkThrow(function () view.setInt32(), Error);1454 checkThrow(function () view.setUint32(), Error);1455 checkThrow(function () view.setFloat32(), Error);1456 checkThrow(function () view.setFloat64(), Error);1457 checkThrow(function () view.setInt8(1), Error);1458 checkThrow(function () view.setUint8(1), Error);1459 checkThrow(function () view.setInt16(1), Error);1460 checkThrow(function () view.setUint16(1), Error);1461 checkThrow(function () view.setInt32(1), Error);1462 checkThrow(function () view.setUint32(1), Error);1463 checkThrow(function () view.setFloat32(1), Error);1464 checkThrow(function () view.setFloat64(1), Error);1465 // testAlignment1466 var intArray1 = [0, 1, 2, 3, 100, 101, 102, 103, 128, 129, 130, 131, 252, 253, 254, 255];1467 view = new DataView((new Uint8Array(intArray1)).buffer, 0);1468 assertEq(view.getUint32(0, false), 0x00010203);1469 view = new DataView((new Uint8Array(intArray1)).buffer, 1);1470 assertEq(view.getUint32(0, false), 0x01020364);1471 view = new DataView((new Uint8Array(intArray1)).buffer, 2);1472 assertEq(view.getUint32(0, false), 0x02036465);1473 view = new DataView((new Uint8Array(intArray1)).buffer, 3);1474 assertEq(view.getUint32(0, false), 0x03646566);1475 view = new DataView((new Uint8Array(intArray1)).buffer, 4);1476 assertEq(view.getUint32(0, false), 0x64656667);1477 view = new DataView((new Uint8Array(intArray1)).buffer, 5);1478 assertEq(view.getUint32(0, false), 0x65666780);1479 view = new DataView((new Uint8Array(intArray1)).buffer, 6);1480 assertEq(view.getUint32(0, false), 0x66678081);1481 view = new DataView((new Uint8Array(intArray1)).buffer, 7);1482 assertEq(view.getUint32(0, false), 0x67808182);1483 // Test for indexing into a DataView, which should not use the ArrayBuffer storage1484 view = new DataView((new Uint8Array([1, 2])).buffer);1485 assertEq(view[0], undefined);1486 view[0] = 3;1487 assertEq(view[0], 3);1488 assertEq(view.getUint8(0), 1);1489 // Test WebIDL-specific class and prototype class names1490 assertEq(Object.prototype.toString.apply(new Uint8Array(0)), "[object Uint8Array]");1491 assertEq(Object.prototype.toString.apply(new Float32Array(0)), "[object Float32Array]");1492 assertEq(Object.prototype.toString.apply(Uint8Array.prototype), "[object Uint8ArrayPrototype]");1493 assertEq(Object.prototype.toString.apply(Float32Array.prototype), "[object Float32ArrayPrototype]");1494 assertEq(Object.prototype.toString.apply(new ArrayBuffer()), "[object ArrayBuffer]");1495 assertEq(Object.prototype.toString.apply(new DataView(view.buffer)), "[object DataView]");1496 assertEq(Object.prototype.toString.apply(DataView.prototype), "[object DataViewPrototype]");1497 // Accessing DataView fields on DataView.prototype should crash1498 checkThrow(function () DataView.prototype.byteLength, TypeError);1499 checkThrow(function () DataView.prototype.byteOffset, TypeError);1500 checkThrow(function () DataView.prototype.buffer, TypeError);1501 // Protos and proxies, oh my!1502 var alien = newGlobal();1503 var alien_data = alien.eval('data = ' + data1.toSource());1504 var alien_buffer = alien.eval('buffer = new Uint8Array(data).buffer');1505 var alien_view = alien.eval('view = new DataView(buffer, 0, 16)');1506 // proto is view of buffer: should throw1507 var o = Object.create(view1);1508 checkThrow(function () o.getUint8(4), TypeError); // WebIDL 4.4.7: Operations1509 checkThrow(function () o.buffer, TypeError); // WebIDL 4.4.6: Attributes, section 21510 checkThrow(function () o.byteOffset, TypeError);1511 checkThrow(function () o.byteLength, TypeError);1512 // proxy for view of buffer: should work1513 assertEq(alien_view.buffer.byteLength > 0, true);1514 assertEq(alien_view.getUint8(4), 100);1515 // Bug 753996: when throwing an Error whose message contains the name of a1516 // function, the JS engine calls js_ValueToFunction to produce the function1517 // name to include in the message. js_ValueToFunction does not unwrap its1518 // argument. So if the function is actually a wrapper, then1519 // js_ValueToFunction will throw a TypeError ("X is not a function").1520 // Confusingly, this TypeError uses the decompiler, which *will* unwrap the1521 // object to get the wrapped function name out, so the final error will1522 // look something like "SomeFunction() is not a function".)1523 var weirdo = Object.create(alien.eval("new Date"));1524 var e = null;1525 try {1526 weirdo.getTime();1527 } catch (exc) {1528 e = exc;1529 }1530 if (!e) {1531 print("==== TODO but PASSED? ====");1532 print("Bug 753996 unexpectedly passed");1533 }1534 // proto is proxy for view of buffer: should throw TypeError1535 //1536 // As of this writing, bug 753996 causes this to throw the *wrong*1537 // TypeError, and in fact it throws a (thisglobal).TypeError instead of1538 // alien.TypeError.1539 var av = Object.create(alien_view);1540 checkThrowTODO(function () av.getUint8(4), alien.TypeError);1541 checkThrowTODO(function () av.buffer, alien.TypeError);1542 // view of object whose proto is buffer. This should not work per dherman.1543 // Note that DataView throws a TypeError while TypedArrays create a1544 // zero-length view. Odd though it seems, this is correct: TypedArrays have1545 // a constructor that takes a length argument; DataViews do not. So a1546 // TypedArray will do ToUint32 and end up passing a zero as the1547 // constructor's length argument.1548 buffer = Object.create(buffer1);1549 checkThrow(function () new DataView(buffer), TypeError);1550 // view of proxy for buffer1551 av = new DataView(alien_buffer);1552 assertEq(av.getUint8(4), 100);1553 assertEq(Object.getPrototypeOf(av), DataView.prototype);1554 // Bug 760904: call another compartment's constructor with an ArrayBuffer1555 // from this compartment, both as a constructor and as a regular call. (The1556 // latter is what was broken in that bug.)1557 var alien_constructor = alien.DataView;1558 var local_buffer = (new Int8Array(3)).buffer;1559 var foreign_exchange_student_1 = alien_constructor(local_buffer);1560 var foreign_exchange_student_2 = new alien_constructor(local_buffer);1561 // gc bug 7877751562 var ab = new ArrayBuffer(4);1563 var dv = new DataView(ab);1564 dv = 1;1565 gc();1566 reportCompare(0, 0, 'done.');1567 exitFunc ('test');1568}...
Mp4Analysis.js
Source:Mp4Analysis.js
1class Mp4Analysis{2 constructor(){3 }4 getInfo(dataView){5 // const dataView = new DataView(buffer);6 // console.log(dataView)7 const info={};8 let minor_version = dataView.getInt32(12);9 const mp4Struct = [];10 this.getMp4Struct(mp4Struct,dataView,0,dataView.byteLength,minor_version);11 // console.log(mp4Struct)12 let moovBox;13 for(let i=0;i<mp4Struct.length;i++){14 if(mp4Struct[i].boxType == 'moov'){15 moovBox = mp4Struct[i];16 break;17 }18 }19 const date = new Date();20 date.setFullYear(1904,0,1);21 date.setHours(0,0,0,0);22 const ms1904 = date.getTime();23 const moovStruct = this.getMoovData(moovBox,dataView,minor_version);24 // let time_scale = 0;25 // console.log(moovStruct)26 for(let i=0;i<moovStruct.length;i++){27 let item = moovStruct[i];28 if(item.boxType == 'mvhd'){29 info.creation_time = Math.max(0,item.info.creation_time*1000+ms1904);30 info.modification_time = Math.max(0,item.info.modification_time*1000+ms1904);31 info.duration = item.info.duration/item.info.time_scale;32 }else if(item.boxType == 'trak'){33 if(item.track_type == 'vide'){34 // let sample_count = item.stts.sample_count;35 // if(sample_count <= 1 && item.stsz.sample_count>1){36 let sample_count = item.stsz.sample_count;37 // }38 info.width = item.stsd.width;39 info.height = item.stsd.height;40 info.video_format = item.stsd.format;41 info.video_frames = sample_count;42 info.video_duration = item.mdhd.duration/item.mdhd.time_scale;43 info.fps = sample_count/info.video_duration;44 info.bit_rate = item.stsz.file_size*8/info.video_duration/1000;45 info.bit_depth = item.stsd.bit_depth;46 }else if(item.track_type == 'soun'){47 // let sample_count = item.stts.sample_count;48 // if(sample_count <= 1 && item.stsz.sample_count>1){49 let sample_count = item.stsz.sample_count;50 // }51 info.audio_format = item.stsd.format;52 info.audio_frames = sample_count;53 info.audio_duration = item.mdhd.duration/item.mdhd.time_scale;54 info.audio_smplrate = item.stsd.smplrate;55 info.audio_channel = item.stsd.channel;56 info.audio_bit_rate = item.stsz.file_size*8/info.audio_duration/1000;57 }58 }59 }60 // console.log('moovStruct',moovStruct)61 return info;62 }63 getMp4Struct(mp4Struct,dataView,positon,side){64 if(positon<0) return;65 let boxLen = dataView.getInt32(positon);66 // let buffer = dataView.buffer.slice(positon+4,positon+8);67 let boxName = this.getASCII(dataView.buffer.slice(positon+4,positon+8));68 mp4Struct.push({69 boxType:boxName,70 boxPosStart:positon,71 boxPosEnd: positon+boxLen72 })73 if(positon+boxLen < side){74 this.getMp4Struct(mp4Struct,dataView,positon+boxLen,side);75 }76 }77 getASCII(buffer){78 const int8 = new Uint8Array(buffer);79 let str = '';80 for(let i=0;i<int8.length;i++){81 str += String.fromCharCode(int8[i]);82 }83 return str;84 }85 getMoovData(recordBox,dataView,minor_version){86 if(!recordBox){87 return null;88 }89 // const moovObj = {90 // mvhd:{}91 // }92 const moovStruct = [];93 this.getMp4Struct(moovStruct,dataView,recordBox.boxPosStart+8,recordBox.boxPosEnd);94 for(let i=0;i<moovStruct.length;i++){95 let item = moovStruct[i];96 if(item.boxType == 'mvhd'){97 item.info = this.decode_mvhd(item,dataView,minor_version);98 }else{99 // item['track'+i] = this.decodeTrack(item,dataView,minor_version);100 const trakStruct = [];101 this.getMp4Struct(trakStruct,dataView,item.boxPosStart+8,item.boxPosEnd);102 item.children = trakStruct;103 for(let j=0;j<trakStruct.length;j++){104 let trak_item = trakStruct[j];105 if(trak_item.boxType == 'tkhd'){106 trak_item.info = this.decode_tkhd(trak_item,dataView,trak_item.boxPosStart+8,trak_item.boxPosEnd);107 }else if(trak_item.boxType == 'mdia'){108 const mdiaStruct = [];109 this.getMp4Struct(mdiaStruct,dataView,trak_item.boxPosStart+8,trak_item.boxPosEnd);110 trak_item.children = mdiaStruct;111 for(let m=0;m<mdiaStruct.length;m++){112 let mdia_item = mdiaStruct[m];113 if(mdia_item.boxType == 'mdhd'){114 mdia_item.info = this.decode_mdhd(mdia_item,dataView,minor_version);115 item.mdhd = mdia_item.info;116 }else if(mdia_item.boxType == 'hdlr'){117 mdia_item.info = this.decode_hdlr(mdia_item,dataView,minor_version);118 trak_item.track_type = mdia_item.info.handler_type;119 item.track_type = mdia_item.info.handler_type;120 }else if(mdia_item.boxType == 'minf'){121 const minfStruct = [];122 this.getMp4Struct(minfStruct,dataView,mdia_item.boxPosStart+8,mdia_item.boxPosEnd);123 mdia_item.children = minfStruct;124 for(let n=0;n<minfStruct.length;n++){125 let minf_item = minfStruct[n];126 if(minf_item.boxType == 'vmhd'){127 minf_item.info = this.decode_vmhd(minf_item,dataView,minor_version);128 }else if(minf_item.boxType == 'smhd'){129 minf_item.info = this.decode_smhd(minf_item,dataView,minor_version);130 }else if(minf_item.boxType == 'stbl'){131 const stblStruct = [];132 this.getMp4Struct(stblStruct,dataView,minf_item.boxPosStart+8,minf_item.boxPosEnd);133 minf_item.children = stblStruct;134 for(let o=0;o<stblStruct.length;o++){135 let stbl_item = stblStruct[o];136 if(stbl_item.boxType == 'stsd'){137 if(trak_item.track_type == 'vide'){138 stbl_item.info = this.decode_stsd_video(stbl_item,dataView,minor_version);139 }else if(trak_item.track_type == 'soun'){140 stbl_item.info = this.decode_stsd_audio(stbl_item,dataView,minor_version);141 }142 item.stsd = stbl_item.info;143 }else if(stbl_item.boxType == 'stts'){144 if(trak_item.track_type == 'vide'){145 stbl_item.info = this.decode_stts_video(stbl_item,dataView,minor_version);146 }else if(trak_item.track_type == 'soun'){147 stbl_item.info = this.decode_stts_audio(stbl_item,dataView,minor_version);148 }149 item.stts = stbl_item.info;150 }else if(stbl_item.boxType == 'stsz'){151 if(trak_item.track_type == 'vide'){152 stbl_item.info = this.decode_stsz_video(stbl_item,dataView,minor_version);153 }else if(trak_item.track_type == 'soun'){154 stbl_item.info = this.decode_stsz_audio(stbl_item,dataView,minor_version);155 }156 item.stsz = stbl_item.info;157 }158 }159 160 }161 }162 }163 }164 }165 }166 // console.log('track'+i,trakStruct)167 }168 }169 return moovStruct;170 }171 decode_mvhd(recordBox,dataView,minor_version){172 const info = {};173 let tempPos = recordBox.boxPosStart+8;174 if(minor_version==1){175 tempPos+=4;176 info.creation_time = dataView.getBigUint64(tempPos);177 tempPos+=8;178 info.modification_time = dataView.getBigUint64(tempPos);179 tempPos+=8;180 info.time_scale = dataView.getUint32(tempPos);181 tempPos+=4;182 info.duration = dataView.getBigUint64(tempPos);183 tempPos+=4;184 }else{185 tempPos+=4;186 info.creation_time = dataView.getUint32(tempPos);187 tempPos+=4;188 info.modification_time = dataView.getUint32(tempPos);189 tempPos+=4;190 info.time_scale = dataView.getUint32(tempPos);191 tempPos+=4;192 info.duration = dataView.getUint32(tempPos);193 tempPos+=4;194 }195 info.rate = dataView.getUint32(tempPos);196 tempPos+=4;197 info.volume = dataView.getUint16(tempPos);198 return info;199 }200 decode_tkhd(recordBox,dataView,minor_version){201 const info = {};202 let tempPos = recordBox.boxPosStart+8;203 info.version = dataView.getUint8(tempPos);204 info.flags = dataView.getUint8(tempPos+3);205 tempPos+=4;206 info.creation_time = dataView.getUint32(tempPos);207 tempPos+=4;208 info.modification_time = dataView.getUint32(tempPos);209 tempPos+=4;210 info.track_id = dataView.getUint32(tempPos);211 tempPos+=4;212 //ä¿ç4ä½213 // info.reserved = dataView.getUint32(tempPos);214 tempPos+=4;215 info.duration = dataView.getUint32(tempPos);216 tempPos+=8;217 //ä¿ç8ä½218 tempPos+=4;219 info.layer = dataView.getUint16(tempPos);220 tempPos+=2;221 info.alternate_group = dataView.getUint16(tempPos);222 tempPos+=2;223 info.volume = dataView.getUint8(tempPos)+dataView.getUint8(tempPos+1)/100;224 tempPos+=2;225 tempPos+=2;226 //ä¿ç2ä½227 tempPos+=36;228 info.width = dataView.getUint16(tempPos);229 tempPos+=4;230 info.height = dataView.getUint16(tempPos);231 232 return info;233 }234 decode_mdhd(recordBox,dataView,minor_version){235 const info = {};236 let tempPos = recordBox.boxPosStart+8;237 info.version = dataView.getUint8(tempPos);238 info.flags = dataView.getUint8(tempPos+3);239 tempPos+=4;240 info.creation_time = dataView.getUint32(tempPos);241 tempPos+=4;242 info.modification_time = dataView.getUint32(tempPos);243 tempPos+=4;244 info.time_scale = dataView.getUint32(tempPos);245 tempPos+=4;246 info.duration = dataView.getUint32(tempPos);247 return info;248 }249 decode_hdlr(recordBox,dataView,minor_version){250 const info = {};251 let tempPos = recordBox.boxPosStart+8;252 info.version = dataView.getUint8(tempPos);253 info.flags = dataView.getUint8(tempPos+3);254 tempPos+=8;255 info.handler_type = this.getASCII(dataView.buffer.slice(tempPos,tempPos+4));256 return info;257 }258 decode_vmhd(recordBox,dataView,minor_version){259 const info = {};260 let tempPos = recordBox.boxPosStart+8;261 info.version = dataView.getUint8(tempPos);262 info.flags = dataView.getUint8(tempPos+3);263 tempPos+=4;264 info.graphics_mode = dataView.getUint32(tempPos);265 return info;266 }267 decode_smhd(recordBox,dataView,minor_version){268 const info = {};269 let tempPos = recordBox.boxPosStart+8;270 info.version = dataView.getUint8(tempPos);271 info.flags = dataView.getUint8(tempPos+3);272 tempPos+=4;273 info.balance = dataView.getInt8(tempPos);274 return info;275 }276 decode_stsd_video(recordBox,dataView,minor_version){277 const info = {};278 let tempPos = recordBox.boxPosStart+8;279 // console.log('atomLen',dataView.getUint32(tempPos-8))280 info.version = dataView.getUint8(tempPos);281 info.flags = dataView.getUint8(tempPos+3);282 tempPos+=4;283 info.sample_descriptions = dataView.getUint32(tempPos);284 tempPos+=4;285 info.size = dataView.getUint32(tempPos);286 tempPos+=4;287 info.format = this.getASCII(dataView.buffer.slice(tempPos,tempPos+4));288 tempPos+=28;289 info.width = dataView.getUint16(tempPos);290 info.height = dataView.getUint16(tempPos+2);291 tempPos += 4;292 info.horizresolution = dataView.getUint32(tempPos);293 info.vertresolution = dataView.getUint32(tempPos+4);294 tempPos += 8;295 info.reserved = dataView.getUint32(tempPos);296 tempPos += 4;297 info.frames_count = dataView.getUint16(tempPos);298 tempPos += 2;299 tempPos += 32;300 info.bit_depth = dataView.getUint16(tempPos);301 tempPos += 2;302 //pre_defined303 // tempPos += 2;304 // let avcC_size = dataView.getUint32(tempPos);305 // tempPos += 4;306 // let avcC_boxName = this.getASCII(dataView.buffer.slice(tempPos,tempPos+4));307 // tempPos += 4;308 // let avc_version = dataView.getUint8(tempPos);309 // let avcProfileIndication = dataView.getUint8(tempPos+1);310 // let profile_compatibility = dataView.getUint8(tempPos+2);311 // let avcLevelIndication = dataView.getUint8(tempPos+3);312 // let NALU_len = dataView.getUint8(tempPos+4);313 // let SPS_number = dataView.getUint8(tempPos+5);314 // tempPos += 6;315 // let SPS_len = dataView.getUint16(tempPos);316 // tempPos += 2;317 // console.log(dataView.buffer.slice(tempPos,tempPos+SPS_len))318 // tempPos += SPS_len;319 // let PPS_number = dataView.getUint8(tempPos);320 // tempPos += 1;321 // let PPS_len = dataView.getUint16(tempPos);322 // tempPos += 2;323 // console.log(dataView.buffer.slice(tempPos,tempPos+PPS_len))324 // console.log(info,avcC_boxName)325 return info;326 }327 decode_stsd_audio(recordBox,dataView,minor_version){328 const info = {};329 let tempPos = recordBox.boxPosStart+8;330 info.version = dataView.getUint8(tempPos);331 info.flags = dataView.getUint8(tempPos+3);332 tempPos+=4;333 info.sample_descriptions = dataView.getUint32(tempPos);334 tempPos+=4;335 info.size = dataView.getUint32(tempPos);336 tempPos+=4;337 info.format = this.getASCII(dataView.buffer.slice(tempPos,tempPos+4));338 tempPos+=20;339 info.channel = dataView.getUint16(tempPos);340 tempPos+=8;341 info.smplrate = dataView.getUint16(tempPos);342 // info.height = dataView.getUint16(tempPos+2);343 return info;344 }345 decode_stts_video(recordBox,dataView,minor_version){346 const info = {};347 let tempPos = recordBox.boxPosStart+8;348 info.version = dataView.getUint8(tempPos);349 info.flags = dataView.getUint8(tempPos+3);350 tempPos+=4;351 info.time_to_sample = dataView.getUint32(tempPos);352 tempPos+=4;353 info.sample_count = dataView.getUint32(tempPos);354 tempPos+=4;355 info.sample_duration = dataView.getUint32(tempPos);356 return info;357 }358 decode_stts_audio(recordBox,dataView,minor_version){359 const info = {};360 let tempPos = recordBox.boxPosStart+8;361 info.version = dataView.getUint8(tempPos);362 info.flags = dataView.getUint8(tempPos+3);363 tempPos+=4;364 info.time_to_sample = dataView.getUint32(tempPos);365 tempPos+=4;366 info.sample_count = dataView.getUint32(tempPos);367 tempPos+=4;368 info.sample_duration = dataView.getUint32(tempPos);369 return info;370 }371 decode_stsz_video(recordBox,dataView,minor_version){372 const info = {};373 let tempPos = recordBox.boxPosStart;374 let sample_count = dataView.getInt32(tempPos+16);375 tempPos += 20;376 let all_size_byte = 0;377 for(let i=0;i<sample_count;i++){378 all_size_byte += dataView.getInt32(tempPos);379 tempPos += 4;380 }381 info.file_size = all_size_byte;382 info.sample_count = sample_count;383 return info;384 }385 decode_stsz_audio(recordBox,dataView,minor_version){386 const info = {};387 let tempPos = recordBox.boxPosStart;388 let sample_count = dataView.getInt32(tempPos+16);389 tempPos += 20;390 let all_size_byte = 0;391 for(let i=0;i<sample_count;i++){392 all_size_byte += dataView.getInt32(tempPos);393 tempPos += 4;394 }395 info.file_size = all_size_byte;396 info.sample_count = sample_count;397 return info;398 }399}...
index.d.ts
Source:index.d.ts
1// Type definitions for three-tds-loader 1.12// Project: https://github.com/codetheorist/three-tds-loader3// Definitions by: Konstantin Lukaschenko <https://github.com/KonstantinLukaschenko>4// Stefan Schönsee <https://github.com/sschoensee>5// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped6// TypeScript Version: 2.87import * as THREE from 'three';8export = TDSLoader;9declare class TDSLoader {10 constructor(three: typeof THREE);11 /**12 * Load 3ds file from url.13 *14 * @param url URL for the file.15 * @param onLoad onLoad callback, receives group object3D as argument.16 * @param onProgress onProgress callback.17 * @param onError onError callback.18 */19 load: (url: string, onLoad: (object3D: THREE.Object3D) => void, onProgress?: (progress: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) => void;20 /**21 * Parse arraybuffer data and load 3ds file.22 *23 * @param arraybuffer Arraybuffer data to be loaded.24 * @param path Path for external resources.25 * @return Group loaded from 3ds file.26 */27 parse: (arraybuffer: ArrayBuffer, path: string) => THREE.Object3D;28 /**29 * Decode file content to read 3ds data.30 *31 * @param arraybuffer Arraybuffer data to be loaded.32 */33 readFile: (arraybuffer: ArrayBuffer, path: string) => void;34 /**35 * Read mesh data chunk.36 *37 * @param data Dataview in use.38 */39 readMeshData: (data: DataView, path: string) => void;40 /**41 * Read named object chunk.42 *43 * @param data Dataview in use.44 */45 readNamedobject: (data: DataView) => void;46 /**47 * Read material data chunk and add it to the material list.48 *49 * @param data Dataview in use.50 */51 readMaterialEntry: (data: DataView, path: string) => void;52 /**53 * Read mesh data chunk.54 *55 * @param data Dataview in use.56 */57 readMesh: (data: DataView) => void;58 /**59 * Read face array data chunk.60 *61 * @param data Dataview in use.62 * @param mesh Mesh to be filled with the data read.63 */64 readFaceArray: (data: DataView, mesh: THREE.Mesh) => void;65 /**66 * Read texture map data chunk.67 *68 * @param data Dataview in use.69 * @return Texture read from this data chunk.70 */71 readMap: (data: DataView, path: string) => THREE.Texture;72 /**73 * Read material group data chunk.74 *75 * @param data Dataview in use.76 * @return object with name and index of the object.77 */78 readMaterialGroup: (data: DataView) => object;79 /**80 * Read a color value.81 *82 * @param data Dataview.83 * @return Color value read..84 */85 readColor: (data: DataView) => THREE.Color;86 /**87 * Read next chunk of data.88 *89 * @param data Dataview.90 * @return Chunk of data read.91 */92 readChunk: (data: DataView) => object;93 /**94 * Set position to the end of the current chunk of data.95 *96 * @param chunk Data chunk.97 */98 endChunk: (chunk: object) => void;99 /**100 * Move to the next data chunk.101 *102 * @param data Dataview.103 * @param chunk Data chunk.104 */105 nextChunk: (data: DataView, chunk: object) => number;106 /**107 * Reset dataview position.108 */109 resetPosition: () => void;110 /**111 * Read byte value.112 *113 * @param data Dataview to read data from.114 * @return Data read from the dataview.115 */116 readByte: (data: DataView) => number;117 /**118 * Read 32 bit float value.119 *120 * @param data Dataview to read data from.121 * @return Data read from the dataview.122 */123 readFloat: (data: DataView) => number;124 /**125 * Read 32 bit signed integer value.126 *127 * @param data Dataview to read data from.128 * @return Data read from the dataview.129 */130 readInt: (data: DataView) => number;131 /**132 * Read 16 bit signed integer value.133 *134 * @param data Dataview to read data from.135 * @return Data read from the dataview.136 */137 readShort: (data: DataView) => number;138 /**139 * Read 64 bit unsigned integer value.140 *141 * @param data Dataview to read data from.142 * @return Data read from the dataview.143 */144 readDWord: (data: DataView) => number;145 /**146 * Read 32 bit unsigned integer value.147 *148 * @param data Dataview to read data from.149 * @return Data read from the dataview.150 */151 readWord: (data: DataView) => number;152 /**153 * Read string value.154 *155 * @param data Dataview to read data from.156 * @param maxLength Max size of the string to be read.157 * @return Data read from the dataview.158 */159 readString: (data: DataView, maxLength: number) => string;160 /**161 * Set resource path used to determine the file path to attached resources.162 *163 * @param path Path to resources.164 * @return Self for chaining.165 */166 setPath: (path: string) => TDSLoader;167 /**168 * Print debug message to the console.169 *170 * Is controlled by a flag to show or hide debug messages.171 *172 * @param message Debug message to print to the console.173 */174 debugMessage: (message: string) => void;...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getLocations(function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10 if (err) {11 console.log(err);12 } else {13 console.log(data);14 }15});16}, function(err, data) {17 if (err) {18 console.log(err);19 } else {20 console.log(data);21 }22});23var testId = '141114_7A_1P23';24wpt.getTestStatus(testId, function(err, data) {25 if (err) {26 console.log(err);27 } else {28 console.log(data);29 }30});31wpt.getTestResults(testId, function(err, data) {32 if (err) {33 console.log(err);34 } else {35 console.log(data);36 }37});38wpt.getTestResults(testId, {39}, function(err, data) {40 if (err) {41 console.log(err);42 } else {43 console.log(data);44 }45});46wpt.getTestResults(testId, {47}, function(err, data) {48 if (err) {49 console.log(err);50 } else {51 console.log(data);52 }53});54wpt.getTestResults(testId, {
Using AI Code Generation
1const wptools = require('wptools');2wptools.page('Barack Obama').then(page => {3 return page.data();4}).then(data => {5 console.log(data);6});7const wptools = require('wptools');8wptools.page('Barack Obama').then(page => {9 return page.get();10}).then(data => {11 console.log(data);12});13const wptools = require('wptools');14wptools.page('Barack Obama').then(page => {15 return page.get();16}).then(data => {17 console.log(data);18});19const wptools = require('wptools');20wptools.page('Barack Obama').then(page => {21 return page.get();22}).then(data => {23 console.log(data);24});25const wptools = require('wptools');26wptools.page('Barack Obama').then(page => {27 return page.get();28}).then(data => {29 console.log(data);30});31const wptools = require('wptools');32wptools.page('Barack Obama').then(page => {33 return page.get();34}).then(data => {35 console.log(data);36});37const wptools = require('wptools');38wptools.page('Barack Obama').then(page => {39 return page.get();40}).then(data => {41 console.log(data);42});43const wptools = require('wptools');44wptools.page('Barack Obama').then(page => {45 return page.get();46}).then(data => {47 console.log(data);48});49const wptools = require('wptools');50wptools.page('Barack Obama').then(page => {51 return page.get();52}).then(data => {53 console.log(data);54});
Using AI Code Generation
1var dataView = require('wptb').DataView();2dataView.get({3 callback: function(err, data) {4 if (err) {5 console.log('Error: ' + err);6 } else {7 console.log('Data: ' + data);8 }9 }10});
Using AI Code Generation
1function dataView() {2 var data = JSON.parse(localStorage.getItem("data"));3 console.log(data);4 var table = document.getElementById("myTable");5 var row = table.insertRow(1);6 var cell1 = row.insertCell(0);7 cell1.innerHTML = data[0].name;8 var cell2 = row.insertCell(1);9 cell2.innerHTML = data[0].address;10 var cell3 = row.insertCell(2);11 cell3.innerHTML = data[0].time;12 var cell4 = row.insertCell(3);13 cell4.innerHTML = data[0].date;14 var cell5 = row.insertCell(4);15 cell5.innerHTML = data[0].type;16 var cell6 = row.insertCell(5);17 cell6.innerHTML = data[0].description;18 var cell7 = row.insertCell(6);19 cell7.innerHTML = data[0].email;20 var cell8 = row.insertCell(7);21 cell8.innerHTML = data[0].phone;22 var cell9 = row.insertCell(8);23 cell9.innerHTML = data[0].status;24 var cell10 = row.insertCell(9);25 cell10.innerHTML = data[0].assignedTo;26 var cell11 = row.insertCell(10);27 cell11.innerHTML = data[0].assignedDate;28 var cell12 = row.insertCell(11);29 cell12.innerHTML = data[0].assignedTime;30}31function dataView2() {32 var data = JSON.parse(localStorage.getItem("data"));33 console.log(data);34 var table = document.getElementById("myTable");35 var row = table.insertRow(1);36 var cell1 = row.insertCell(0);37 cell1.innerHTML = data[1].name;38 var cell2 = row.insertCell(1);39 cell2.innerHTML = data[1].address;40 var cell3 = row.insertCell(2);41 cell3.innerHTML = data[1].time;42 var cell4 = row.insertCell(3);43 cell4.innerHTML = data[1].date;44 var cell5 = row.insertCell(4);45 cell5.innerHTML = data[1].type;46 var cell6 = row.insertCell(5);47 cell6.innerHTML = data[1].description;
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var testId = '160809_9H_1e9c0b6a8b7f2c2d0b7a1c1f8e7d3b1a';4var data = 'run';5var type = 'json';6var callback = function(err, data) {7 if (err) return console.error(err);8 console.log(data);9}10wpt.dataView(testId, data, type, callback);11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org');13var testId = '160809_9H_1e9c0b6a8b7f2c2d0b7a1c1f8e7d3b1a';14var data = 'run';15var type = 'json';16var callback = function(err, data) {17 if (err) return console.error(err);18 console.log(data);19}20wpt.dataView(testId, data, type, callback);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!