How to use enumerate_props method in wpt

Best JavaScript code snippet using wpt

common.js

Source:common.js Github

copy

Full Screen

...46 if (test_obj && !callback_is_async)47 test_obj.done();48 }49}50function enumerate_props(compare_func, test_obj) {51 return function(actual, input) {52 for (var x in input) {53 compare_func(actual[x], input[x], test_obj);54 }55 };56}57check('primitive undefined', undefined, compare_primitive);58check('primitive null', null, compare_primitive);59check('primitive true', true, compare_primitive);60check('primitive false', false, compare_primitive);61check('primitive string, empty string', '', compare_primitive);62check('primitive string, lone high surrogate', '\uD800', compare_primitive);63check('primitive string, lone low surrogate', '\uDC00', compare_primitive);64check('primitive string, NUL', '\u0000', compare_primitive);65check('primitive string, astral character', '\uDBFF\uDFFD', compare_primitive);66check('primitive number, 0.2', 0.2, compare_primitive);67check('primitive number, 0', 0, compare_primitive);68check('primitive number, -0', -0, compare_primitive);69check('primitive number, NaN', NaN, compare_primitive);70check('primitive number, Infinity', Infinity, compare_primitive);71check('primitive number, -Infinity', -Infinity, compare_primitive);72check('primitive number, 9007199254740992', 9007199254740992, compare_primitive);73check('primitive number, -9007199254740992', -9007199254740992, compare_primitive);74check('primitive number, 9007199254740994', 9007199254740994, compare_primitive);75check('primitive number, -9007199254740994', -9007199254740994, compare_primitive);76check('Array primitives', [undefined,77 null,78 true,79 false,80 '',81 '\uD800',82 '\uDC00',83 '\u0000',84 '\uDBFF\uDFFD',85 0.2,86 0,87 -0,88 NaN,89 Infinity,90 -Infinity,91 9007199254740992,92 -9007199254740992,93 9007199254740994,94 -9007199254740994], compare_Array(enumerate_props(compare_primitive)));95check('Object primitives', {'undefined':undefined,96 'null':null,97 'true':true,98 'false':false,99 'empty':'',100 'high surrogate':'\uD800',101 'low surrogate':'\uDC00',102 'nul':'\u0000',103 'astral':'\uDBFF\uDFFD',104 '0.2':0.2,105 '0':0,106 '-0':-0,107 'NaN':NaN,108 'Infinity':Infinity,109 '-Infinity':-Infinity,110 '9007199254740992':9007199254740992,111 '-9007199254740992':-9007199254740992,112 '9007199254740994':9007199254740994,113 '-9007199254740994':-9007199254740994}, compare_Object(enumerate_props(compare_primitive)));114function compare_Boolean(actual, input, test_obj) {115 if (typeof actual === 'string')116 assert_unreached(actual);117 assert_true(actual instanceof Boolean, 'instanceof Boolean');118 assert_equals(String(actual), String(input), 'converted to primitive');119 assert_not_equals(actual, input);120 if (test_obj)121 test_obj.done();122}123check('Boolean true', new Boolean(true), compare_Boolean);124check('Boolean false', new Boolean(false), compare_Boolean);125check('Array Boolean objects', [new Boolean(true), new Boolean(false)], compare_Array(enumerate_props(compare_Boolean)));126check('Object Boolean objects', {'true':new Boolean(true), 'false':new Boolean(false)}, compare_Object(enumerate_props(compare_Boolean)));127function compare_obj(what) {128 var Type = window[what];129 return function(actual, input, test_obj) {130 if (typeof actual === 'string')131 assert_unreached(actual);132 assert_true(actual instanceof Type, 'instanceof '+what);133 assert_equals(Type(actual), Type(input), 'converted to primitive');134 assert_not_equals(actual, input);135 if (test_obj)136 test_obj.done();137 };138}139check('String empty string', new String(''), compare_obj('String'));140check('String lone high surrogate', new String('\uD800'), compare_obj('String'));141check('String lone low surrogate', new String('\uDC00'), compare_obj('String'));142check('String NUL', new String('\u0000'), compare_obj('String'));143check('String astral character', new String('\uDBFF\uDFFD'), compare_obj('String'));144check('Array String objects', [new String(''),145 new String('\uD800'),146 new String('\uDC00'),147 new String('\u0000'),148 new String('\uDBFF\uDFFD')], compare_Array(enumerate_props(compare_obj('String'))));149check('Object String objects', {'empty':new String(''),150 'high surrogate':new String('\uD800'),151 'low surrogate':new String('\uDC00'),152 'nul':new String('\u0000'),153 'astral':new String('\uDBFF\uDFFD')}, compare_Object(enumerate_props(compare_obj('String'))));154check('Number 0.2', new Number(0.2), compare_obj('Number'));155check('Number 0', new Number(0), compare_obj('Number'));156check('Number -0', new Number(-0), compare_obj('Number'));157check('Number NaN', new Number(NaN), compare_obj('Number'));158check('Number Infinity', new Number(Infinity), compare_obj('Number'));159check('Number -Infinity', new Number(-Infinity), compare_obj('Number'));160check('Number 9007199254740992', new Number(9007199254740992), compare_obj('Number'));161check('Number -9007199254740992', new Number(-9007199254740992), compare_obj('Number'));162check('Number 9007199254740994', new Number(9007199254740994), compare_obj('Number'));163check('Number -9007199254740994', new Number(-9007199254740994), compare_obj('Number'));164check('Array Number objects', [new Number(0.2),165 new Number(0),166 new Number(-0),167 new Number(NaN),168 new Number(Infinity),169 new Number(-Infinity),170 new Number(9007199254740992),171 new Number(-9007199254740992),172 new Number(9007199254740994),173 new Number(-9007199254740994)], compare_Array(enumerate_props(compare_obj('Number'))));174check('Object Number objects', {'0.2':new Number(0.2),175 '0':new Number(0),176 '-0':new Number(-0),177 'NaN':new Number(NaN),178 'Infinity':new Number(Infinity),179 '-Infinity':new Number(-Infinity),180 '9007199254740992':new Number(9007199254740992),181 '-9007199254740992':new Number(-9007199254740992),182 '9007199254740994':new Number(9007199254740994),183 '-9007199254740994':new Number(-9007199254740994)}, compare_Object(enumerate_props(compare_obj('Number'))));184function compare_Date(actual, input, test_obj) {185 if (typeof actual === 'string')186 assert_unreached(actual);187 assert_true(actual instanceof Date, 'instanceof Date');188 assert_equals(Number(actual), Number(input), 'converted to primitive');189 assert_not_equals(actual, input);190 if (test_obj)191 test_obj.done();192}193check('Date 0', new Date(0), compare_Date);194check('Date -0', new Date(-0), compare_Date);195check('Date -8.64e15', new Date(-8.64e15), compare_Date);196check('Date 8.64e15', new Date(8.64e15), compare_Date);197check('Array Date objects', [new Date(0),198 new Date(-0),199 new Date(-8.64e15),200 new Date(8.64e15)], compare_Array(enumerate_props(compare_Date)));201check('Object Date objects', {'0':new Date(0),202 '-0':new Date(-0),203 '-8.64e15':new Date(-8.64e15),204 '8.64e15':new Date(8.64e15)}, compare_Object(enumerate_props(compare_Date)));205function compare_RegExp(expected_source) {206 // XXX ES6 spec doesn't define exact serialization for `source` (it allows several ways to escape)207 return function(actual, input, test_obj) {208 if (typeof actual === 'string')209 assert_unreached(actual);210 assert_true(actual instanceof RegExp, 'instanceof RegExp');211 assert_equals(actual.global, input.global, 'global');212 assert_equals(actual.ignoreCase, input.ignoreCase, 'ignoreCase');213 assert_equals(actual.multiline, input.multiline, 'multiline');214 assert_equals(actual.source, expected_source, 'source');215 assert_equals(actual.sticky, input.sticky, 'sticky');216 assert_equals(actual.unicode, input.unicode, 'unicode');217 assert_equals(actual.lastIndex, 0, 'lastIndex');218 assert_not_equals(actual, input);219 if (test_obj)220 test_obj.done();221 }222}223function func_RegExp_flags_lastIndex() {224 var r = /foo/gim;225 r.lastIndex = 2;226 return r;227}228function func_RegExp_sticky() {229 return new RegExp('foo', 'y');230}231function func_RegExp_unicode() {232 return new RegExp('foo', 'u');233}234check('RegExp flags and lastIndex', func_RegExp_flags_lastIndex, compare_RegExp('foo'));235check('RegExp sticky flag', func_RegExp_sticky, compare_RegExp('foo'));236check('RegExp unicode flag', func_RegExp_unicode, compare_RegExp('foo'));237check('RegExp empty', new RegExp(''), compare_RegExp('(?:)'));238check('RegExp slash', new RegExp('/'), compare_RegExp('\\/'));239check('RegExp new line', new RegExp('\n'), compare_RegExp('\\n'));240check('Array RegExp object, RegExp flags and lastIndex', [func_RegExp_flags_lastIndex()], compare_Array(enumerate_props(compare_RegExp('foo'))));241check('Array RegExp object, RegExp sticky flag', function() { return [func_RegExp_sticky()]; }, compare_Array(enumerate_props(compare_RegExp('foo'))));242check('Array RegExp object, RegExp unicode flag', function() { return [func_RegExp_unicode()]; }, compare_Array(enumerate_props(compare_RegExp('foo'))));243check('Array RegExp object, RegExp empty', [new RegExp('')], compare_Array(enumerate_props(compare_RegExp('(?:)'))));244check('Array RegExp object, RegExp slash', [new RegExp('/')], compare_Array(enumerate_props(compare_RegExp('\\/'))));245check('Array RegExp object, RegExp new line', [new RegExp('\n')], compare_Array(enumerate_props(compare_RegExp('\\n'))));246check('Object RegExp object, RegExp flags and lastIndex', {'x':func_RegExp_flags_lastIndex()}, compare_Object(enumerate_props(compare_RegExp('foo'))));247check('Object RegExp object, RegExp sticky flag', function() { return {'x':func_RegExp_sticky()}; }, compare_Object(enumerate_props(compare_RegExp('foo'))));248check('Object RegExp object, RegExp unicode flag', function() { return {'x':func_RegExp_unicode()}; }, compare_Object(enumerate_props(compare_RegExp('foo'))));249check('Object RegExp object, RegExp empty', {'x':new RegExp('')}, compare_Object(enumerate_props(compare_RegExp('(?:)'))));250check('Object RegExp object, RegExp slash', {'x':new RegExp('/')}, compare_Object(enumerate_props(compare_RegExp('\\/'))));251check('Object RegExp object, RegExp new line', {'x':new RegExp('\n')}, compare_Object(enumerate_props(compare_RegExp('\\n'))));252function compare_Blob(actual, input, test_obj, expect_File) {253 if (typeof actual === 'string')254 assert_unreached(actual);255 assert_true(actual instanceof Blob, 'instanceof Blob');256 if (!expect_File)257 assert_false(actual instanceof File, 'instanceof File');258 assert_equals(actual.size, input.size, 'size');259 assert_equals(actual.type, input.type, 'type');260 assert_not_equals(actual, input);261 var ev_reader = new FileReader();262 var input_reader = new FileReader();263 var read_count = 0;264 var read_done = test_obj.step_func(function() {265 read_count++;266 if (read_count == 2) {267 var ev_result = ev_reader.result;268 var input_result = input_reader.result;269 assert_equals(ev_result.byteLength, input_result.byteLength, 'byteLength');270 var ev_view = new DataView(ev_result);271 var input_view = new DataView(input_result);272 for (var i = 0; i < ev_result.byteLength; ++i) {273 assert_equals(ev_view.getUint8(i), input_view.getUint8(i), 'getUint8('+i+')');274 }275 if (test_obj)276 test_obj.done();277 }278 });279 var read_error = test_obj.step_func(function() { assert_unreached('FileReader error'); });280 ev_reader.readAsArrayBuffer(actual);281 ev_reader.onload = read_done;282 ev_reader.onabort = ev_reader.onerror = read_error;283 input_reader.readAsArrayBuffer(input);284 input_reader.onload = read_done;285 input_reader.onabort = input_reader.onerror = read_error;286}287function func_Blob_basic() {288 return new Blob(['foo'], {type:'text/x-bar'});289}290check('Blob basic', func_Blob_basic, compare_Blob);291function b(str) {292 return parseInt(str, 2);293}294function encode_cesu8(codeunits) {295 // http://www.unicode.org/reports/tr26/ section 2.2296 // only the 3-byte form is supported297 var rv = [];298 codeunits.forEach(function(codeunit) {299 rv.push(b('11100000') + ((codeunit & b('1111000000000000')) >> 12));300 rv.push(b('10000000') + ((codeunit & b('0000111111000000')) >> 6));301 rv.push(b('10000000') + (codeunit & b('0000000000111111')));302 });303 return rv;304}305function func_Blob_bytes(arr) {306 return function() {307 var buffer = new ArrayBuffer(arr.length);308 var view = new DataView(buffer);309 for (var i = 0; i < arr.length; ++i) {310 view.setUint8(i, arr[i]);311 }312 return new Blob([view]);313 };314}315check('Blob unpaired high surrogate (invalid utf-8)', func_Blob_bytes(encode_cesu8([0xD800])), compare_Blob);316check('Blob unpaired low surrogate (invalid utf-8)', func_Blob_bytes(encode_cesu8([0xDC00])), compare_Blob);317check('Blob paired surrogates (invalid utf-8)', func_Blob_bytes(encode_cesu8([0xD800, 0xDC00])), compare_Blob);318function func_Blob_empty() {319 return new Blob(['']);320}321check('Blob empty', func_Blob_empty , compare_Blob);322function func_Blob_NUL() {323 return new Blob(['\u0000']);324}325check('Blob NUL', func_Blob_NUL, compare_Blob);326async_test(function(test_obj) {327 check(test_obj.name, [test_obj.step(func_Blob_basic)], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);328}, 'Array Blob object, Blob basic');329async_test(function(test_obj) {330 check(test_obj.name, [test_obj.step(func_Blob_bytes([0xD800]))], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);331}, 'Array Blob object, Blob unpaired high surrogate (invalid utf-8)');332async_test(function(test_obj) {333 check(test_obj.name, [test_obj.step(func_Blob_bytes([0xDC00]))], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);334}, 'Array Blob object, Blob unpaired low surrogate (invalid utf-8)');335async_test(function(test_obj) {336 check(test_obj.name, [test_obj.step(func_Blob_bytes([0xD800, 0xDC00]))], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);337}, 'Array Blob object, Blob paired surrogates (invalid utf-8)');338async_test(function(test_obj) {339 check(test_obj.name, [test_obj.step(func_Blob_empty)], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);340}, 'Array Blob object, Blob empty');341async_test(function(test_obj) {342 check(test_obj.name, [test_obj.step(func_Blob_NUL)], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);343}, 'Array Blob object, Blob NUL');344async_test(function(test_obj) {345 check(test_obj.name, {'x':test_obj.step(func_Blob_basic)}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);346}, 'Object Blob object, Blob basic');347async_test(function(test_obj) {348 check(test_obj.name, {'x':test_obj.step(func_Blob_bytes([0xD800]))}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);349}, 'Object Blob object, Blob unpaired high surrogate (invalid utf-8)');350async_test(function(test_obj) {351 check(test_obj.name, {'x':test_obj.step(func_Blob_bytes([0xDC00]))}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);352}, 'Object Blob object, Blob unpaired low surrogate (invalid utf-8)');353async_test(function(test_obj) {354 check(test_obj.name, {'x':test_obj.step(func_Blob_bytes([0xD800, 0xDC00]))}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);355}, 'Object Blob object, Blob paired surrogates (invalid utf-8)');356async_test(function(test_obj) {357 check(test_obj.name, {'x':test_obj.step(func_Blob_empty)}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);358}, 'Object Blob object, Blob empty');359async_test(function(test_obj) {360 check(test_obj.name, {'x':test_obj.step(func_Blob_NUL)}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);361}, 'Object Blob object, Blob NUL');362function compare_File(actual, input, test_obj) {363 assert_true(actual instanceof File, 'instanceof File');364 assert_equals(actual.name, input.name, 'name');365 assert_equals(actual.lastModified, input.lastModified, 'lastModified');366 compare_Blob(actual, input, test_obj, true);367}368function func_File_basic() {369 return new File(['foo'], 'bar', {type:'text/x-bar', lastModified:42});370}371check('File basic', func_File_basic, compare_File);372function compare_FileList(actual, input, test_obj) {373 if (typeof actual === 'string')374 assert_unreached(actual);375 assert_true(actual instanceof FileList, 'instanceof FileList');376 assert_equals(actual.length, input.length, 'length');377 assert_not_equals(actual, input);378 // XXX when there's a way to populate or construct a FileList,379 // check the items in the FileList380 if (test_obj)381 test_obj.done();382}383function func_FileList_empty() {384 var input = document.createElement('input');385 input.type = 'file';386 return input.files;387}388check('FileList empty', func_FileList_empty, compare_FileList);389check('Array FileList object, FileList empty', [func_FileList_empty], compare_Array(enumerate_props(compare_FileList)));390check('Object FileList object, FileList empty', {'x':func_FileList_empty}, compare_Object(enumerate_props(compare_FileList)));391function compare_ArrayBufferView(view) {392 var Type = window[view];393 return function(actual, input, test_obj) {394 if (typeof actual === 'string')395 assert_unreached(actual);396 assert_true(actual instanceof Type, 'instanceof '+view);397 assert_equals(actual.length, input.length, 'length');398 assert_not_equals(actual.buffer, input.buffer, 'buffer');399 for (var i = 0; i < actual.length; ++i) {400 assert_equals(actual[i], input[i], 'actual['+i+']');401 }402 if (test_obj)403 test_obj.done();404 };405}406function compare_ImageData(actual, input, test_obj) {407 if (typeof actual === 'string')408 assert_unreached(actual);409 assert_equals(actual.width, input.width, 'width');410 assert_equals(actual.height, input.height, 'height');411 assert_not_equals(actual.data, input.data, 'data');412 compare_ArrayBufferView('Uint8ClampedArray')(actual.data, input.data, null);413 if (test_obj)414 test_obj.done();415}416function func_ImageData_1x1_transparent_black() {417 var canvas = document.createElement('canvas');418 var ctx = canvas.getContext('2d');419 return ctx.createImageData(1, 1);420}421check('ImageData 1x1 transparent black', func_ImageData_1x1_transparent_black, compare_ImageData);422function func_ImageData_1x1_non_transparent_non_black() {423 var canvas = document.createElement('canvas');424 var ctx = canvas.getContext('2d');425 var imagedata = ctx.createImageData(1, 1);426 imagedata.data[0] = 100;427 imagedata.data[1] = 101;428 imagedata.data[2] = 102;429 imagedata.data[3] = 103;430 return imagedata;431}432check('ImageData 1x1 non-transparent non-black', func_ImageData_1x1_non_transparent_non_black, compare_ImageData);433async_test(function(test_obj) {434 check(test_obj.name, [test_obj.step(func_ImageData_1x1_transparent_black)], compare_Array(enumerate_props(compare_ImageData)), test_obj);435}, 'Array ImageData object, ImageData 1x1 transparent black');436async_test(function(test_obj) {437 check(test_obj.name, [test_obj.step(func_ImageData_1x1_non_transparent_non_black)], compare_Array(enumerate_props(compare_ImageData)), test_obj);438}, 'Array ImageData object, ImageData 1x1 non-transparent non-black');439async_test(function(test_obj) {440 check(test_obj.name, {'x':test_obj.step(func_ImageData_1x1_transparent_black)}, compare_Object(enumerate_props(compare_ImageData)), test_obj);441}, 'Object ImageData object, ImageData 1x1 transparent black');442async_test(function(test_obj) {443 check(test_obj.name, {'x':test_obj.step(func_ImageData_1x1_non_transparent_non_black)}, compare_Object(enumerate_props(compare_ImageData)), test_obj);444}, 'Object ImageData object, ImageData 1x1 non-transparent non-black');445function compare_ImageBitmap(actual, input, test_obj) {446 if (typeof actual === 'string')447 assert_unreached(actual);448 assert_equals(actual instanceof ImageBitmap, 'instanceof ImageBitmap');449 assert_not_equals(actual, input);450 // XXX paint the ImageBitmap on a canvas and check the data451 if (test_obj)452 test_obj.done();453}454function get_canvas_1x1_transparent_black() {455 var canvas = document.createElement('canvas');456 canvas.width = 1;457 canvas.height = 1;458 return canvas;459}460async_test(function(test_obj) {461 var canvas = get_canvas_1x1_transparent_black();462 createImageBitmap(canvas, function(image) { check(test_obj.name, image, compare_ImageBitmap, test_obj); });463}, 'ImageBitmap 1x1 transparent black');464function get_canvas_1x1_non_transparent_non_black() {465 var canvas = document.createElement('canvas');466 canvas.width = 1;467 canvas.height = 1;468 var ctx = canvas.getContext('2d');469 var imagedata = ctx.getImageData(0, 0, 1, 1);470 imagedata.data[0] = 100;471 imagedata.data[1] = 101;472 imagedata.data[2] = 102;473 imagedata.data[3] = 103;474 return canvas;475}476async_test(function(test_obj) {477 var canvas = get_canvas_1x1_non_transparent_non_black();478 createImageBitmap(canvas, function(image) { check(test_obj.name, image, compare_ImageBitmap, test_obj); });479}, 'ImageBitmap 1x1 non-transparent non-black');480async_test(function(test_obj) {481 var canvas = get_canvas_1x1_transparent_black();482 createImageBitmap(canvas, function(image) { check(test_obj.name, [image], compare_Array(enumerate_props(compare_ImageBitmap)), test_obj); });483}, 'Array ImageBitmap object, ImageBitmap 1x1 transparent black');484async_test(function(test_obj) {485 var canvas = get_canvas_1x1_non_transparent_non_black();486 createImageBitmap(canvas, function(image) { check(test_obj.name, [image], compare_Array(enumerate_props(compare_ImageBitmap)), test_obj); });487}, 'Array ImageBitmap object, ImageBitmap 1x1 non-transparent non-black');488async_test(function(test_obj) {489 var canvas = get_canvas_1x1_transparent_black();490 createImageBitmap(canvas, function(image) { check(test_obj.name, {'x':image}, compare_Object(enumerate_props(compare_ImageBitmap)), test_obj); });491}, 'Object ImageBitmap object, ImageBitmap 1x1 transparent black');492async_test(function(test_obj) {493 var canvas = get_canvas_1x1_non_transparent_non_black();494 createImageBitmap(canvas, function(image) { check(test_obj.name, {'x':image}, compare_Object(enumerate_props(compare_ImageBitmap)), test_obj); });495}, 'Object ImageBitmap object, ImageBitmap 1x1 non-transparent non-black');496check('Array sparse', new Array(10), compare_Array(enumerate_props(compare_primitive)));497check('Array with non-index property', function() {498 var rv = [];499 rv.foo = 'bar';500 return rv;501}, compare_Array(enumerate_props(compare_primitive)));502check('Object with index property and length', {'0':'foo', 'length':1}, compare_Object(enumerate_props(compare_primitive)));503function check_circular_property(prop) {504 return function(actual) {505 assert_equals(actual[prop], actual);506 };507}508check('Array with circular reference', function() {509 var rv = [];510 rv[0] = rv;511 return rv;512}, compare_Array(check_circular_property('0')));513check('Object with circular reference', function() {514 var rv = {};515 rv['x'] = rv;516 return rv;...

Full Screen

Full Screen

structured-clone-battery-of-tests.js

Source:structured-clone-battery-of-tests.js Github

copy

Full Screen

...46 if (test_obj && !callback_is_async)47 test_obj.done();48 }49}50function enumerate_props(compare_func, test_obj) {51 return function(actual, input) {52 for (const x in input) {53 compare_func(actual[x], input[x], test_obj);54 }55 };56}57check('primitive undefined', undefined, compare_primitive);58check('primitive null', null, compare_primitive);59check('primitive true', true, compare_primitive);60check('primitive false', false, compare_primitive);61check('primitive string, empty string', '', compare_primitive);62check('primitive string, lone high surrogate', '\uD800', compare_primitive);63check('primitive string, lone low surrogate', '\uDC00', compare_primitive);64check('primitive string, NUL', '\u0000', compare_primitive);65check('primitive string, astral character', '\uDBFF\uDFFD', compare_primitive);66check('primitive number, 0.2', 0.2, compare_primitive);67check('primitive number, 0', 0, compare_primitive);68check('primitive number, -0', -0, compare_primitive);69check('primitive number, NaN', NaN, compare_primitive);70check('primitive number, Infinity', Infinity, compare_primitive);71check('primitive number, -Infinity', -Infinity, compare_primitive);72check('primitive number, 9007199254740992', 9007199254740992, compare_primitive);73check('primitive number, -9007199254740992', -9007199254740992, compare_primitive);74check('primitive number, 9007199254740994', 9007199254740994, compare_primitive);75check('primitive number, -9007199254740994', -9007199254740994, compare_primitive);76check('primitive BigInt, 0n', 0n, compare_primitive);77check('primitive BigInt, -0n', -0n, compare_primitive);78check('primitive BigInt, -9007199254740994000n', -9007199254740994000n, compare_primitive);79check('primitive BigInt, -9007199254740994000900719925474099400090071992547409940009007199254740994000n', -9007199254740994000900719925474099400090071992547409940009007199254740994000n, compare_primitive);80check('Array primitives', [undefined,81 null,82 true,83 false,84 '',85 '\uD800',86 '\uDC00',87 '\u0000',88 '\uDBFF\uDFFD',89 0.2,90 0,91 -0,92 NaN,93 Infinity,94 -Infinity,95 9007199254740992,96 -9007199254740992,97 9007199254740994,98 -9007199254740994,99 -12n,100 -0n,101 0n], compare_Array(enumerate_props(compare_primitive)));102check('Object primitives', {'undefined':undefined,103 'null':null,104 'true':true,105 'false':false,106 'empty':'',107 'high surrogate':'\uD800',108 'low surrogate':'\uDC00',109 'nul':'\u0000',110 'astral':'\uDBFF\uDFFD',111 '0.2':0.2,112 '0':0,113 '-0':-0,114 'NaN':NaN,115 'Infinity':Infinity,116 '-Infinity':-Infinity,117 '9007199254740992':9007199254740992,118 '-9007199254740992':-9007199254740992,119 '9007199254740994':9007199254740994,120 '-9007199254740994':-9007199254740994}, compare_Object(enumerate_props(compare_primitive)));121function compare_Boolean(actual, input, test_obj) {122 if (typeof actual === 'string')123 assert_unreached(actual);124 assert_true(actual instanceof Boolean, 'instanceof Boolean');125 assert_equals(String(actual), String(input), 'converted to primitive');126 assert_not_equals(actual, input);127 if (test_obj)128 test_obj.done();129}130check('Boolean true', new Boolean(true), compare_Boolean);131check('Boolean false', new Boolean(false), compare_Boolean);132check('Array Boolean objects', [new Boolean(true), new Boolean(false)], compare_Array(enumerate_props(compare_Boolean)));133check('Object Boolean objects', {'true':new Boolean(true), 'false':new Boolean(false)}, compare_Object(enumerate_props(compare_Boolean)));134function compare_obj(what) {135 const Type = self[what];136 return function(actual, input, test_obj) {137 if (typeof actual === 'string')138 assert_unreached(actual);139 assert_true(actual instanceof Type, 'instanceof '+what);140 assert_equals(Type(actual), Type(input), 'converted to primitive');141 assert_not_equals(actual, input);142 if (test_obj)143 test_obj.done();144 };145}146check('String empty string', new String(''), compare_obj('String'));147check('String lone high surrogate', new String('\uD800'), compare_obj('String'));148check('String lone low surrogate', new String('\uDC00'), compare_obj('String'));149check('String NUL', new String('\u0000'), compare_obj('String'));150check('String astral character', new String('\uDBFF\uDFFD'), compare_obj('String'));151check('Array String objects', [new String(''),152 new String('\uD800'),153 new String('\uDC00'),154 new String('\u0000'),155 new String('\uDBFF\uDFFD')], compare_Array(enumerate_props(compare_obj('String'))));156check('Object String objects', {'empty':new String(''),157 'high surrogate':new String('\uD800'),158 'low surrogate':new String('\uDC00'),159 'nul':new String('\u0000'),160 'astral':new String('\uDBFF\uDFFD')}, compare_Object(enumerate_props(compare_obj('String'))));161check('Number 0.2', new Number(0.2), compare_obj('Number'));162check('Number 0', new Number(0), compare_obj('Number'));163check('Number -0', new Number(-0), compare_obj('Number'));164check('Number NaN', new Number(NaN), compare_obj('Number'));165check('Number Infinity', new Number(Infinity), compare_obj('Number'));166check('Number -Infinity', new Number(-Infinity), compare_obj('Number'));167check('Number 9007199254740992', new Number(9007199254740992), compare_obj('Number'));168check('Number -9007199254740992', new Number(-9007199254740992), compare_obj('Number'));169check('Number 9007199254740994', new Number(9007199254740994), compare_obj('Number'));170check('Number -9007199254740994', new Number(-9007199254740994), compare_obj('Number'));171// BigInt does not have a non-throwing constructor172check('BigInt -9007199254740994n', Object(-9007199254740994n), compare_obj('BigInt'));173check('Array Number objects', [new Number(0.2),174 new Number(0),175 new Number(-0),176 new Number(NaN),177 new Number(Infinity),178 new Number(-Infinity),179 new Number(9007199254740992),180 new Number(-9007199254740992),181 new Number(9007199254740994),182 new Number(-9007199254740994)], compare_Array(enumerate_props(compare_obj('Number'))));183check('Object Number objects', {'0.2':new Number(0.2),184 '0':new Number(0),185 '-0':new Number(-0),186 'NaN':new Number(NaN),187 'Infinity':new Number(Infinity),188 '-Infinity':new Number(-Infinity),189 '9007199254740992':new Number(9007199254740992),190 '-9007199254740992':new Number(-9007199254740992),191 '9007199254740994':new Number(9007199254740994),192 '-9007199254740994':new Number(-9007199254740994)}, compare_Object(enumerate_props(compare_obj('Number'))));193function compare_Date(actual, input, test_obj) {194 if (typeof actual === 'string')195 assert_unreached(actual);196 assert_true(actual instanceof Date, 'instanceof Date');197 assert_equals(Number(actual), Number(input), 'converted to primitive');198 assert_not_equals(actual, input);199 if (test_obj)200 test_obj.done();201}202check('Date 0', new Date(0), compare_Date);203check('Date -0', new Date(-0), compare_Date);204check('Date -8.64e15', new Date(-8.64e15), compare_Date);205check('Date 8.64e15', new Date(8.64e15), compare_Date);206check('Array Date objects', [new Date(0),207 new Date(-0),208 new Date(-8.64e15),209 new Date(8.64e15)], compare_Array(enumerate_props(compare_Date)));210check('Object Date objects', {'0':new Date(0),211 '-0':new Date(-0),212 '-8.64e15':new Date(-8.64e15),213 '8.64e15':new Date(8.64e15)}, compare_Object(enumerate_props(compare_Date)));214function compare_RegExp(expected_source) {215 // XXX ES6 spec doesn't define exact serialization for `source` (it allows several ways to escape)216 return function(actual, input, test_obj) {217 if (typeof actual === 'string')218 assert_unreached(actual);219 assert_true(actual instanceof RegExp, 'instanceof RegExp');220 assert_equals(actual.global, input.global, 'global');221 assert_equals(actual.ignoreCase, input.ignoreCase, 'ignoreCase');222 assert_equals(actual.multiline, input.multiline, 'multiline');223 assert_equals(actual.source, expected_source, 'source');224 assert_equals(actual.sticky, input.sticky, 'sticky');225 assert_equals(actual.unicode, input.unicode, 'unicode');226 assert_equals(actual.lastIndex, 0, 'lastIndex');227 assert_not_equals(actual, input);228 if (test_obj)229 test_obj.done();230 }231}232function func_RegExp_flags_lastIndex() {233 const r = /foo/gim;234 r.lastIndex = 2;235 return r;236}237function func_RegExp_sticky() {238 return new RegExp('foo', 'y');239}240function func_RegExp_unicode() {241 return new RegExp('foo', 'u');242}243check('RegExp flags and lastIndex', func_RegExp_flags_lastIndex, compare_RegExp('foo'));244check('RegExp sticky flag', func_RegExp_sticky, compare_RegExp('foo'));245check('RegExp unicode flag', func_RegExp_unicode, compare_RegExp('foo'));246check('RegExp empty', new RegExp(''), compare_RegExp('(?:)'));247check('RegExp slash', new RegExp('/'), compare_RegExp('\\/'));248check('RegExp new line', new RegExp('\n'), compare_RegExp('\\n'));249check('Array RegExp object, RegExp flags and lastIndex', [func_RegExp_flags_lastIndex()], compare_Array(enumerate_props(compare_RegExp('foo'))));250check('Array RegExp object, RegExp sticky flag', function() { return [func_RegExp_sticky()]; }, compare_Array(enumerate_props(compare_RegExp('foo'))));251check('Array RegExp object, RegExp unicode flag', function() { return [func_RegExp_unicode()]; }, compare_Array(enumerate_props(compare_RegExp('foo'))));252check('Array RegExp object, RegExp empty', [new RegExp('')], compare_Array(enumerate_props(compare_RegExp('(?:)'))));253check('Array RegExp object, RegExp slash', [new RegExp('/')], compare_Array(enumerate_props(compare_RegExp('\\/'))));254check('Array RegExp object, RegExp new line', [new RegExp('\n')], compare_Array(enumerate_props(compare_RegExp('\\n'))));255check('Object RegExp object, RegExp flags and lastIndex', {'x':func_RegExp_flags_lastIndex()}, compare_Object(enumerate_props(compare_RegExp('foo'))));256check('Object RegExp object, RegExp sticky flag', function() { return {'x':func_RegExp_sticky()}; }, compare_Object(enumerate_props(compare_RegExp('foo'))));257check('Object RegExp object, RegExp unicode flag', function() { return {'x':func_RegExp_unicode()}; }, compare_Object(enumerate_props(compare_RegExp('foo'))));258check('Object RegExp object, RegExp empty', {'x':new RegExp('')}, compare_Object(enumerate_props(compare_RegExp('(?:)'))));259check('Object RegExp object, RegExp slash', {'x':new RegExp('/')}, compare_Object(enumerate_props(compare_RegExp('\\/'))));260check('Object RegExp object, RegExp new line', {'x':new RegExp('\n')}, compare_Object(enumerate_props(compare_RegExp('\\n'))));261async function compare_Blob(actual, input, test_obj, expect_File) {262 if (typeof actual === 'string')263 assert_unreached(actual);264 assert_true(actual instanceof Blob, 'instanceof Blob');265 if (!expect_File)266 assert_false(actual instanceof File, 'instanceof File');267 assert_equals(actual.size, input.size, 'size');268 assert_equals(actual.type, input.type, 'type');269 assert_not_equals(actual, input);270 const ab1 = await new Response(actual).arrayBuffer();271 const ab2 = await new Response(input).arrayBuffer();272 assert_equals(ab1.byteLength, ab2.byteLength, 'byteLength');273 const ta1 = new Uint8Array(ab1);274 const ta2 = new Uint8Array(ab2);275 for(let i = 0; i < ta1.size; i++) {276 assert_equals(ta1[i], ta2[i]);277 }278}279function func_Blob_basic() {280 return new Blob(['foo'], {type:'text/x-bar'});281}282check('Blob basic', func_Blob_basic, compare_Blob);283function b(str) {284 return parseInt(str, 2);285}286function encode_cesu8(codeunits) {287 // http://www.unicode.org/reports/tr26/ section 2.2288 // only the 3-byte form is supported289 const rv = [];290 codeunits.forEach(function(codeunit) {291 rv.push(b('11100000') + ((codeunit & b('1111000000000000')) >> 12));292 rv.push(b('10000000') + ((codeunit & b('0000111111000000')) >> 6));293 rv.push(b('10000000') + (codeunit & b('0000000000111111')));294 });295 return rv;296}297function func_Blob_bytes(arr) {298 return function() {299 const buffer = new ArrayBuffer(arr.length);300 const view = new DataView(buffer);301 for (let i = 0; i < arr.length; ++i) {302 view.setUint8(i, arr[i]);303 }304 return new Blob([view]);305 };306}307check('Blob unpaired high surrogate (invalid utf-8)', func_Blob_bytes(encode_cesu8([0xD800])), compare_Blob);308check('Blob unpaired low surrogate (invalid utf-8)', func_Blob_bytes(encode_cesu8([0xDC00])), compare_Blob);309check('Blob paired surrogates (invalid utf-8)', func_Blob_bytes(encode_cesu8([0xD800, 0xDC00])), compare_Blob);310function func_Blob_empty() {311 return new Blob(['']);312}313check('Blob empty', func_Blob_empty , compare_Blob);314function func_Blob_NUL() {315 return new Blob(['\u0000']);316}317check('Blob NUL', func_Blob_NUL, compare_Blob);318check('Array Blob object, Blob basic', [func_Blob_basic()], compare_Array(enumerate_props(compare_Blob), true));319check('Array Blob object, Blob unpaired high surrogate (invalid utf-8)', [func_Blob_bytes([0xD800])()], compare_Array(enumerate_props(compare_Blob), true));320check('Array Blob object, Blob unpaired low surrogate (invalid utf-8)', [func_Blob_bytes([0xDC00])()], compare_Array(enumerate_props(compare_Blob), true));321check('Array Blob object, Blob paired surrogates (invalid utf-8)', [func_Blob_bytes([0xD800, 0xDC00])()], compare_Array(enumerate_props(compare_Blob), true));322check('Array Blob object, Blob empty', [func_Blob_empty()], compare_Array(enumerate_props(compare_Blob), true));323check('Array Blob object, Blob NUL', [func_Blob_NUL()], compare_Array(enumerate_props(compare_Blob), true));324check('Array Blob object, two Blobs', [func_Blob_basic(), func_Blob_empty()], compare_Array(enumerate_props(compare_Blob), true));325check('Object Blob object, Blob basic', {'x':func_Blob_basic()}, compare_Object(enumerate_props(compare_Blob), true));326check('Object Blob object, Blob unpaired high surrogate (invalid utf-8)', {'x':func_Blob_bytes([0xD800])()}, compare_Object(enumerate_props(compare_Blob), true));327check('Object Blob object, Blob unpaired low surrogate (invalid utf-8)', {'x':func_Blob_bytes([0xDC00])()}, compare_Object(enumerate_props(compare_Blob), true));328check('Object Blob object, Blob paired surrogates (invalid utf-8)', {'x':func_Blob_bytes([0xD800, 0xDC00])() }, compare_Object(enumerate_props(compare_Blob), true));329check('Object Blob object, Blob empty', {'x':func_Blob_empty()}, compare_Object(enumerate_props(compare_Blob), true));330check('Object Blob object, Blob NUL', {'x':func_Blob_NUL()}, compare_Object(enumerate_props(compare_Blob), true));331function compare_File(actual, input, test_obj) {332 assert_true(actual instanceof File, 'instanceof File');333 assert_equals(actual.name, input.name, 'name');334 assert_equals(actual.lastModified, input.lastModified, 'lastModified');335 compare_Blob(actual, input, test_obj, true);336}337function func_File_basic() {338 return new File(['foo'], 'bar', {type:'text/x-bar', lastModified:42});339}340check('File basic', func_File_basic, compare_File);341function compare_FileList(actual, input, test_obj) {342 if (typeof actual === 'string')343 assert_unreached(actual);344 assert_true(actual instanceof FileList, 'instanceof FileList');345 assert_equals(actual.length, input.length, 'length');346 assert_not_equals(actual, input);347 // XXX when there's a way to populate or construct a FileList,348 // check the items in the FileList349 if (test_obj)350 test_obj.done();351}352function func_FileList_empty() {353 const input = document.createElement('input');354 input.type = 'file';355 return input.files;356}357check('FileList empty', func_FileList_empty, compare_FileList, true);358check('Array FileList object, FileList empty', () => ([func_FileList_empty()]), compare_Array(enumerate_props(compare_FileList)), true);359check('Object FileList object, FileList empty', () => ({'x':func_FileList_empty()}), compare_Object(enumerate_props(compare_FileList)), true);360function compare_ArrayBufferView(view) {361 const Type = self[view];362 return function(actual, input, test_obj) {363 if (typeof actual === 'string')364 assert_unreached(actual);365 assert_true(actual instanceof Type, 'instanceof '+view);366 assert_equals(actual.length, input.length, 'length');367 assert_not_equals(actual.buffer, input.buffer, 'buffer');368 for (let i = 0; i < actual.length; ++i) {369 assert_equals(actual[i], input[i], 'actual['+i+']');370 }371 if (test_obj)372 test_obj.done();373 };374}375function compare_ImageData(actual, input, test_obj) {376 if (typeof actual === 'string')377 assert_unreached(actual);378 assert_equals(actual.width, input.width, 'width');379 assert_equals(actual.height, input.height, 'height');380 assert_not_equals(actual.data, input.data, 'data');381 compare_ArrayBufferView('Uint8ClampedArray')(actual.data, input.data, null);382 if (test_obj)383 test_obj.done();384}385function func_ImageData_1x1_transparent_black() {386 const canvas = document.createElement('canvas');387 const ctx = canvas.getContext('2d');388 return ctx.createImageData(1, 1);389}390check('ImageData 1x1 transparent black', func_ImageData_1x1_transparent_black, compare_ImageData, true);391function func_ImageData_1x1_non_transparent_non_black() {392 const canvas = document.createElement('canvas');393 const ctx = canvas.getContext('2d');394 const imagedata = ctx.createImageData(1, 1);395 imagedata.data[0] = 100;396 imagedata.data[1] = 101;397 imagedata.data[2] = 102;398 imagedata.data[3] = 103;399 return imagedata;400}401check('ImageData 1x1 non-transparent non-black', func_ImageData_1x1_non_transparent_non_black, compare_ImageData, true);402check('Array ImageData object, ImageData 1x1 transparent black', () => ([func_ImageData_1x1_transparent_black()]), compare_Array(enumerate_props(compare_ImageData)), true);403check('Array ImageData object, ImageData 1x1 non-transparent non-black', () => ([func_ImageData_1x1_non_transparent_non_black()]), compare_Array(enumerate_props(compare_ImageData)), true);404check('Object ImageData object, ImageData 1x1 transparent black', () => ({'x':func_ImageData_1x1_transparent_black()}), compare_Object(enumerate_props(compare_ImageData)), true);405check('Object ImageData object, ImageData 1x1 non-transparent non-black', () => ({'x':func_ImageData_1x1_non_transparent_non_black()}), compare_Object(enumerate_props(compare_ImageData)), true);406check('Array sparse', new Array(10), compare_Array(enumerate_props(compare_primitive)));407check('Array with non-index property', function() {408 const rv = [];409 rv.foo = 'bar';410 return rv;411}, compare_Array(enumerate_props(compare_primitive)));412check('Object with index property and length', {'0':'foo', 'length':1}, compare_Object(enumerate_props(compare_primitive)));413function check_circular_property(prop) {414 return function(actual) {415 assert_equals(actual[prop], actual);416 };417}418check('Array with circular reference', function() {419 const rv = [];420 rv[0] = rv;421 return rv;422}, compare_Array(check_circular_property('0')));423check('Object with circular reference', function() {424 const rv = {};425 rv['x'] = rv;426 return rv;427}, compare_Object(check_circular_property('x')));428function check_identical_property_values(prop1, prop2) {429 return function(actual) {430 assert_equals(actual[prop1], actual[prop2]);431 };432}433check('Array with identical property values', function() {434 const obj = {}435 return [obj, obj];436}, compare_Array(check_identical_property_values('0', '1')));437check('Object with identical property values', function() {438 const obj = {}439 return {'x':obj, 'y':obj};440}, compare_Object(check_identical_property_values('x', 'y')));441function check_absent_property(prop) {442 return function(actual) {443 assert_false(prop in actual);444 };445}446check('Object with property on prototype', function() {447 const Foo = function() {};448 Foo.prototype = {'foo':'bar'};449 return new Foo();450}, compare_Object(check_absent_property('foo')));451check('Object with non-enumerable property', function() {452 const rv = {};453 Object.defineProperty(rv, 'foo', {value:'bar', enumerable:false, writable:true, configurable:true});454 return rv;455}, compare_Object(check_absent_property('foo')));456function check_writable_property(prop) {457 return function(actual, input) {458 assert_equals(actual[prop], input[prop]);459 actual[prop] += ' baz';460 assert_equals(actual[prop], input[prop] + ' baz');461 };462}463check('Object with non-writable property', function() {464 const rv = {};465 Object.defineProperty(rv, 'foo', {value:'bar', enumerable:true, writable:false, configurable:true});466 return rv;467}, compare_Object(check_writable_property('foo')));468function check_configurable_property(prop) {469 return function(actual, input) {470 assert_equals(actual[prop], input[prop]);471 delete actual[prop];472 assert_false('prop' in actual);473 };474}475check('Object with non-configurable property', function() {476 const rv = {};477 Object.defineProperty(rv, 'foo', {value:'bar', enumerable:true, writable:true, configurable:false});478 return rv;479}, compare_Object(check_configurable_property('foo')));480/* The tests below are inspired by @zcorpan’s work but got some481more substantial changed due to their previous async setup */482function get_canvas_1x1_transparent_black() {483 const canvas = document.createElement('canvas');484 canvas.width = 1;485 canvas.height = 1;486 return canvas;487}488function get_canvas_1x1_non_transparent_non_black() {489 const canvas = document.createElement('canvas');490 canvas.width = 1;491 canvas.height = 1;492 const ctx = canvas.getContext('2d');493 const imagedata = ctx.getImageData(0, 0, 1, 1);494 imagedata.data[0] = 100;495 imagedata.data[1] = 101;496 imagedata.data[2] = 102;497 imagedata.data[3] = 103;498 return canvas;499}500function compare_ImageBitmap(actual, input) {501 if (typeof actual === 'string')502 assert_unreached(actual);503 assert_true(actual instanceof ImageBitmap, 'instanceof ImageBitmap');504 assert_not_equals(actual, input);505 // XXX paint the ImageBitmap on a canvas and check the data506}507structuredCloneBatteryOfTests.push({508 description: 'ImageBitmap 1x1 transparent black',509 async f(runner) {510 const canvas = get_canvas_1x1_transparent_black();511 const bm = await createImageBitmap(canvas);512 const copy = await runner.structuredClone(bm);513 compare_ImageBitmap(bm, copy);514 },515 requiresDocument: true516});517structuredCloneBatteryOfTests.push({518 description: 'ImageBitmap 1x1 non-transparent non-black',519 async f(runner) {520 const canvas = get_canvas_1x1_non_transparent_non_black();521 const bm = await createImageBitmap(canvas);522 const copy = await runner.structuredClone(bm);523 compare_ImageBitmap(bm, copy);524 },525 requiresDocument: true526});527structuredCloneBatteryOfTests.push({528 description: 'Array ImageBitmap object, ImageBitmap 1x1 transparent black',529 async f(runner) {530 const canvas = get_canvas_1x1_transparent_black();531 const bm = [await createImageBitmap(canvas)];532 const copy = await runner.structuredClone(bm);533 compare_Array(enumerate_props(compare_ImageBitmap))(bm, copy);534 },535 requiresDocument: true536});537structuredCloneBatteryOfTests.push({538 description: 'Array ImageBitmap object, ImageBitmap 1x1 transparent non-black',539 async f(runner) {540 const canvas = get_canvas_1x1_non_transparent_non_black();541 const bm = [await createImageBitmap(canvas)];542 const copy = await runner.structuredClone(bm);543 compare_Array(enumerate_props(compare_ImageBitmap))(bm, copy);544 },545 requiresDocument: true546});547structuredCloneBatteryOfTests.push({548 description: 'Object ImageBitmap object, ImageBitmap 1x1 transparent black',549 async f(runner) {550 const canvas = get_canvas_1x1_transparent_black();551 const bm = {x: await createImageBitmap(canvas)};552 const copy = await runner.structuredClone(bm);553 compare_Object(enumerate_props(compare_ImageBitmap))(bm, copy);554 },555 requiresDocument: true556});557structuredCloneBatteryOfTests.push({558 description: 'Object ImageBitmap object, ImageBitmap 1x1 transparent non-black',559 async f(runner) {560 const canvas = get_canvas_1x1_non_transparent_non_black();561 const bm = {x: await createImageBitmap(canvas)};562 const copy = await runner.structuredClone(bm);563 compare_Object(enumerate_props(compare_ImageBitmap))(bm, copy);564 },565 requiresDocument: true566});567check('ObjectPrototype must lose its exotic-ness when cloned',568 () => Object.prototype,569 (copy, original) => {570 assert_not_equals(copy, original);571 assert_true(copy instanceof Object);572 const newProto = { some: 'proto' };573 // Must not throw:574 Object.setPrototypeOf(copy, newProto);575 assert_equals(Object.getPrototypeOf(copy), newProto);576 }577);

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new ActiveXObject("WPT.WPT");2var obj = {a: 1, b: 2, c: 3};3var props = wpt.enumerate_props(obj);4WScript.Echo(props.join(", "));5var wpt = new ActiveXObject("WPT.WPT");6var obj = {a: 1, b: 2, c: 3};7var props = wpt.enumerate_props(obj);8WScript.Echo(props.join(", "));9var wpt = new ActiveXObject("WPT.WPT");10var obj = {a: 1, b: 2, c: 3};11var props = wpt.enumerate_props(obj);12WScript.Echo(props.join(", "));13var wpt = new ActiveXObject("WPT.WPT");14var obj = {a: 1, b: 2, c: 3};15var props = wpt.enumerate_props(obj);16WScript.Echo(props.join(", "));17var wpt = new ActiveXObject("WPT.WPT");18var obj = {a: 1, b: 2, c: 3};19var props = wpt.enumerate_props(obj);20WScript.Echo(props.join(", "));21var wpt = new ActiveXObject("WPT.WPT");22var obj = {a: 1, b: 2, c: 3};23var props = wpt.enumerate_props(obj);24WScript.Echo(props.join(", "));25var wpt = new ActiveXObject("WPT.WPT");26var obj = {a: 1, b: 2, c: 3};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new WPT();2var props = wpt.enumerate_props();3for (var i = 0; i < props.length; i++)4{5 WScript.Echo(props[i]);6}7For i = 0 to UBound(props)8 WScript.Echo props(i)9var wpt = new WPT();10var props = wpt.enumerate_props();11for (var i = 0; i < props.length; i++)12{13 WScript.Echo(props[i]);14}15For i = 0 to UBound(props)16 WScript.Echo props(i)17var wpt = new WPT();18var props = wpt.enumerate_props();19for (var i = 0; i < props.length; i++)20{21 WScript.Echo(props[i]);22}23For i = 0 to UBound(props)24 WScript.Echo props(i)25var wpt = new WPT();26var props = wpt.enumerate_props();27for (var i = 0; i < props.length; i++)28{29 WScript.Echo(props[i]);30}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptb = require('wptb');2var obj = {a:1, b:2, c:3};3var props = wptb.enumerate_props(obj);4console.log(props);5var wptb = require('wptb');6var obj = {a:1, b:2, c:3};7var props = wptb.enumerate_props(obj, true);8console.log(props);9var wptb = require('wptb');10var obj = {a:1, b:2, c:3};11var props = wptb.enumerate_props(obj, true, true);12console.log(props);13var wptb = require('wptb');14var obj = {a:1, b:2, c:3};15var props = wptb.enumerate_props(obj, false, true);16console.log(props);17var wptb = require('wptb');18var obj = {a:1, b:2, c:3};19var props = wptb.enumerate_props(obj, false, false);20console.log(props);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var wp = new wptoolkit();3var props = wp.enumerate_props();4console.log(props);5var wptoolkit = require('wptoolkit');6var wp = new wptoolkit();7var taxonomies = wp.enumerate_taxonomies();8console.log(taxonomies);9var wptoolkit = require('wptoolkit');10var wp = new wptoolkit();11var post_types = wp.enumerate_post_types();12console.log(post_types);13var wptoolkit = require('wptoolkit');14var wp = new wptoolkit();15var post = wp.get_post(1);16console.log(post);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new ActiveXObject("WebPageTest");2var props = wpt.enumerate_props();3var arr = props.split(",");4for(var i=0; i<arr.length; i++)5{6 WScript.Echo(arr[i]);7}8Set wpt = CreateObject("WebPageTest")9props = wpt.enumerate_props()10arr = Split(props, ",")11For i = 0 To UBound(arr)12 WScript.Echo arr(i)13var wpt = new ActiveXObject("WebPageTest");14var methods = wpt.enumerate_methods();15var arr = methods.split(",");16for(var i=0; i<arr.length; i++)17{18 WScript.Echo(arr[i]);19}20Set wpt = CreateObject("WebPageTest")21methods = wpt.enumerate_methods()22arr = Split(methods, ",")23For i = 0 To UBound(arr)24 WScript.Echo arr(i)25var wpt = new ActiveXObject("WebPageTest");26var events = wpt.enumerate_events();27var arr = events.split(",");28for(var i=0; i<arr.length; i++)29{30 WScript.Echo(arr[i]);31}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptext = require('wptext');2var text = "This is a test string. It has two sentences. The first sentence is short. The second sentence is long.";3var props = wptext.enumerate_props(text);4console.log(props);5var wptext = require('wptext');6var text = "This is a test string. It has two sentences. The first sentence is short. The second sentence is long.";7var props = wptext.enumerate_props(text);8console.log(props);9var wptext = require('wptext');10var text = "This is a test string. It has two sentences. The first sentence is short. The second sentence is long.";11var props = wptext.enumerate_props(text);12console.log(props);13var wptext = require('wptext');14var text = "This is a test string. It has two sentences. The first sentence is short. The second sentence is long.";15var props = wptext.enumerate_props(text);16console.log(props);17var wptext = require('wptext');18var text = "This is a test string. It has two sentences. The first sentence is short. The second sentence is long.";19var props = wptext.enumerate_props(text);20console.log(props);21var wptext = require('wptext');

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful