Skip to content

Commit

Permalink
Merge branch 'main' into roll-chromium-m109
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade committed Dec 6, 2022
2 parents b917d1f + 17f31a9 commit efa7da7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
38 changes: 21 additions & 17 deletions packages/puppeteer-core/src/common/types.ts
Expand Up @@ -135,32 +135,36 @@ type BeginSubclassSelectorTokens = ['.', '#', '[', ':'];

type CombinatorTokens = [' ', '>', '+', '~', '|', '|'];

type Drop<Arr extends readonly unknown[], Remove> = Arr extends [
infer Head,
...infer Tail
]
type Drop<
Arr extends readonly unknown[],
Remove,
Acc extends unknown[] = []
> = Arr extends [infer Head, ...infer Tail]
? Head extends Remove
? Drop<Tail, Remove>
: [Head, ...Drop<Tail, Remove>]
: [];
: Drop<Tail, Remove, [...Acc, Head]>
: Acc;

type FlatmapSplitWithDelemiters<
Inputs extends readonly string[],
Delemiters extends readonly string[]
Delemiters extends readonly string[],
Acc extends string[] = []
> = Inputs extends [infer FirstInput, ...infer RestInputs]
? FirstInput extends string
? RestInputs extends readonly string[]
? [
...SplitWithDelemiters<FirstInput, Delemiters>,
...FlatmapSplitWithDelemiters<RestInputs, Delemiters>
]
: never
: never
: [];
? FlatmapSplitWithDelemiters<
RestInputs,
Delemiters,
[...Acc, ...SplitWithDelemiters<FirstInput, Delemiters>]
>
: Acc
: Acc
: Acc;

type Split<
Input extends string,
Delemiter extends string
Delemiter extends string,
Acc extends string[] = []
> = Input extends `${infer Prefix}${Delemiter}${infer Suffix}`
? [Prefix, ...Split<Suffix, Delemiter>]
: [Input];
? Split<Suffix, Delemiter, [...Acc, Prefix]>
: [...Acc, Input];
12 changes: 12 additions & 0 deletions test-d/NodeFor.test-d.ts
Expand Up @@ -6,6 +6,18 @@ declare const nodeFor: <Selector extends string>(
) => NodeFor<Selector>;

{
{
expectType<HTMLTableRowElement>(
nodeFor(
'[data-testid="my-component"] div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div tbody tr'
)
);
expectNotType<Element>(
nodeFor(
'[data-testid="my-component"] div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div div tbody tr'
)
);
}
{
expectType<HTMLAnchorElement>(nodeFor('a'));
expectNotType<Element>(nodeFor('a'));
Expand Down
10 changes: 8 additions & 2 deletions test/TestExpectations.json
Expand Up @@ -2124,13 +2124,19 @@
"expectations": ["PASS", "FAIL"]
},
{
"testIdPattern": "[waittask.spec] waittask specs Frame.waitForSelector should survive cross-process navigation",
"testIdPattern": "[waittask.spec] waittask specs Frame.waitForFunction should survive cross-process navigation",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["firefox"],
"expectations": ["PASS", "FAIL"]
},
{
"testIdPattern": "[waittask.spec] waittask specs Frame.waitForFunction should survive cross-process navigation",
"testIdPattern": "[waittask.spec] waittask specs Frame.waitForFunction should work when resolved right before execution context disposal",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["firefox"],
"expectations": ["SKIP"]
},
{
"testIdPattern": "[waittask.spec] waittask specs Frame.waitForSelector should survive cross-process navigation",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["firefox"],
"expectations": ["PASS", "FAIL"]
Expand Down
1 change: 1 addition & 0 deletions test/src/waittask.spec.ts
Expand Up @@ -48,6 +48,7 @@ describe('waittask specs', function () {
await page.waitForFunction(() => {
if (!(globalThis as any).__RELOADED) {
window.location.reload();
return false;
}
return true;
});
Expand Down

0 comments on commit efa7da7

Please sign in to comment.