Commit 87646f76 authored by Mathias Bynens's avatar Mathias Bynens Committed by Commit Bot

[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/+/2848460Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74148}
parent 98300313
...@@ -202,6 +202,7 @@ String16 descriptionForRegExp(v8::Isolate* isolate, ...@@ -202,6 +202,7 @@ String16 descriptionForRegExp(v8::Isolate* isolate,
description.append(toProtocolString(isolate, value->GetSource())); description.append(toProtocolString(isolate, value->GetSource()));
description.append('/'); description.append('/');
v8::RegExp::Flags flags = value->GetFlags(); 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::kGlobal) description.append('g');
if (flags & v8::RegExp::Flags::kIgnoreCase) description.append('i'); if (flags & v8::RegExp::Flags::kIgnoreCase) description.append('i');
if (flags & v8::RegExp::Flags::kLinear) description.append('l'); if (flags & v8::RegExp::Flags::kLinear) description.append('l');
......
...@@ -397,6 +397,16 @@ Running test: testBigInt ...@@ -397,6 +397,16 @@ Running test: testBigInt
} }
Running test: testRegExp 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 '/w+/g', returnByValue: false, generatePreview: false
{ {
result : { result : {
...@@ -457,11 +467,11 @@ Running test: testRegExp ...@@ -457,11 +467,11 @@ Running test: testRegExp
type : object type : object
} }
} }
'/w+/gimsuy', returnByValue: false, generatePreview: false '/w+/dgimsuy', returnByValue: false, generatePreview: false
{ {
result : { result : {
className : RegExp className : RegExp
description : /w+/gimsuy description : /w+/dgimsuy
objectId : <objectId> objectId : <objectId>
subtype : regexp subtype : regexp
type : object type : object
......
...@@ -200,6 +200,9 @@ InspectorTest.runAsyncTestSuite([ ...@@ -200,6 +200,9 @@ InspectorTest.runAsyncTestSuite([
})).result); })).result);
}, },
async function testRegExp() { async function testRegExp() {
InspectorTest.logMessage((await evaluate({
expression: '/\w+/d'
})).result);
InspectorTest.logMessage((await evaluate({ InspectorTest.logMessage((await evaluate({
expression: '/\w+/g' expression: '/\w+/g'
})).result); })).result);
...@@ -219,7 +222,7 @@ InspectorTest.runAsyncTestSuite([ ...@@ -219,7 +222,7 @@ InspectorTest.runAsyncTestSuite([
expression: '/\w+/y' expression: '/\w+/y'
})).result); })).result);
InspectorTest.logMessage((await evaluate({ InspectorTest.logMessage((await evaluate({
expression: '/\w+/gimsuy' expression: '/\w+/dgimsuy'
})).result); })).result);
InspectorTest.logMessage((await evaluate({ InspectorTest.logMessage((await evaluate({
expression: `new RegExp('\\w+', 'g')`, expression: `new RegExp('\\w+', 'g')`,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment