OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 print('Checks internal [[Entries]] in Runtime.getProperties output'); |
| 6 |
| 7 Protocol.Runtime.enable(); |
| 8 |
| 9 InspectorTest.runTestSuite([ |
| 10 function maps(next) { |
| 11 checkExpression('new Map([[1,2],[3,4]])') |
| 12 .then(() => checkExpression('new Map()')) |
| 13 .then(next); |
| 14 }, |
| 15 |
| 16 function mapIterators(next) { |
| 17 checkExpression('new Map([[1,2],[3,4]]).entries()') |
| 18 .then(() => checkExpression('it = new Map([[1,2],[3,4]]).entries(); it.nex
t(); it')) |
| 19 .then(() => checkExpression('it = new Map([[1,2],[3,4]]).keys(); it.next()
; it')) |
| 20 .then(() => checkExpression('it = new Map([[1,2],[3,4]]).values(); it.next
(); it')) |
| 21 .then(() => checkExpression('it = new Map([[1,2],[3,4]]).entries(); it.nex
t(); it.next(); it')) |
| 22 .then(next); |
| 23 }, |
| 24 |
| 25 function sets(next) { |
| 26 checkExpression('new Set([1,2])') |
| 27 .then(() => checkExpression('new Set()')) |
| 28 .then(next); |
| 29 }, |
| 30 |
| 31 function setIterators(next) { |
| 32 checkExpression('new Set([1,2]).values()') |
| 33 .then(() => checkExpression('it = new Set([1,2]).values(); it.next(); it')
) |
| 34 .then(() => checkExpression('it = new Set([1,2]).keys(); it.next(); it')) |
| 35 .then(() => checkExpression('it = new Set([1,2]).entries(); it.next(); it'
)) |
| 36 .then(() => checkExpression('it = new Set([1,2]).values(); it.next(); it.n
ext(); it')) |
| 37 .then(next); |
| 38 }, |
| 39 |
| 40 function weakMaps(next) { |
| 41 checkExpression('new WeakMap()') |
| 42 .then(() => checkExpression('new WeakMap([[{ a: 2 }, 42]])')) |
| 43 .then(next); |
| 44 }, |
| 45 |
| 46 function weakSets(next) { |
| 47 checkExpression('new WeakSet()') |
| 48 .then(() => checkExpression('new WeakSet([{a:2}])')) |
| 49 .then(next); |
| 50 } |
| 51 ]); |
| 52 |
| 53 function checkExpression(expression) |
| 54 { |
| 55 InspectorTest.log(`expression: ${expression}`); |
| 56 var entriesObjectId; |
| 57 return Protocol.Runtime.evaluate({ expression: expression }) |
| 58 .then(message => Protocol.Runtime.getProperties({ objectId: message.result.r
esult.objectId })) |
| 59 .then(message => message.result.internalProperties.filter(p => p.name === '[
[Entries]]')[0]) |
| 60 .then(entries => entriesObjectId = entries.value.objectId) |
| 61 .then(() => Protocol.Runtime.callFunctionOn({ objectId: entriesObjectId, fun
ctionDeclaration: 'function f() { return this; }', returnByValue: true })) |
| 62 .then(message => InspectorTest.logMessage(message.result.result.value)) |
| 63 .then(() => Protocol.Runtime.getProperties({ objectId: entriesObjectId, ownP
roperties: true })) |
| 64 .then(message => InspectorTest.logMessage(message)); |
| 65 } |
OLD | NEW |