[inspector] Add support for the RegExp d flag

Prior to this patch, the RemoteObject for e.g. `/x/d` got a
`description` that omitted the new `d` (`hasIndices`) flag.

Bug: v8:11684, v8:9548
Change-Id: I774fbd9620c6f3f2f19b819c9009fab7cc2e3229
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2848460
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74148}
This commit is contained in:
Mathias Bynens 2021-04-23 15:16:43 +02:00 committed by Commit Bot
parent 98300313b3
commit 87646f76ed
3 changed files with 17 additions and 3 deletions

View File

@ -202,6 +202,7 @@ String16 descriptionForRegExp(v8::Isolate* isolate,
description.append(toProtocolString(isolate, value->GetSource()));
description.append('/');
v8::RegExp::Flags flags = value->GetFlags();
if (flags & v8::RegExp::Flags::kHasIndices) description.append('d');
if (flags & v8::RegExp::Flags::kGlobal) description.append('g');
if (flags & v8::RegExp::Flags::kIgnoreCase) description.append('i');
if (flags & v8::RegExp::Flags::kLinear) description.append('l');

View File

@ -397,6 +397,16 @@ Running test: testBigInt
}
Running test: testRegExp
'/w+/d', returnByValue: false, generatePreview: false
{
result : {
className : RegExp
description : /w+/d
objectId : <objectId>
subtype : regexp
type : object
}
}
'/w+/g', returnByValue: false, generatePreview: false
{
result : {
@ -457,11 +467,11 @@ Running test: testRegExp
type : object
}
}
'/w+/gimsuy', returnByValue: false, generatePreview: false
'/w+/dgimsuy', returnByValue: false, generatePreview: false
{
result : {
className : RegExp
description : /w+/gimsuy
description : /w+/dgimsuy
objectId : <objectId>
subtype : regexp
type : object

View File

@ -200,6 +200,9 @@ InspectorTest.runAsyncTestSuite([
})).result);
},
async function testRegExp() {
InspectorTest.logMessage((await evaluate({
expression: '/\w+/d'
})).result);
InspectorTest.logMessage((await evaluate({
expression: '/\w+/g'
})).result);
@ -219,7 +222,7 @@ InspectorTest.runAsyncTestSuite([
expression: '/\w+/y'
})).result);
InspectorTest.logMessage((await evaluate({
expression: '/\w+/gimsuy'
expression: '/\w+/dgimsuy'
})).result);
InspectorTest.logMessage((await evaluate({
expression: `new RegExp('\\w+', 'g')`,