-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bidi] [js] Add storage module (#13684)
- Loading branch information
Showing
7 changed files
with
711 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
const { SameSite } = require('./networkTypes') | ||
|
||
class CookieFilter { | ||
#map = new Map() | ||
|
||
name(name) { | ||
this.#map.set('name', name) | ||
return this | ||
} | ||
|
||
value(value) { | ||
this.#map.set('value', Object.fromEntries(value.asMap())) | ||
return this | ||
} | ||
|
||
domain(domain) { | ||
this.#map.set('domain', domain) | ||
return this | ||
} | ||
|
||
path(path) { | ||
this.#map.set('path', path) | ||
return this | ||
} | ||
|
||
size(size) { | ||
this.#map.set('size', size) | ||
return this | ||
} | ||
|
||
httpOnly(httpOnly) { | ||
this.#map.set('httpOnly', httpOnly) | ||
return this | ||
} | ||
|
||
secure(secure) { | ||
this.#map.set('secure', secure) | ||
return this | ||
} | ||
|
||
sameSite(sameSite) { | ||
if (!(sameSite instanceof SameSite)) { | ||
throw new Error(`Params must be a value in SameSite. Received:'${sameSite}'`) | ||
} | ||
this.#map.set('sameSite', sameSite) | ||
return this | ||
} | ||
|
||
expiry(expiry) { | ||
this.#map.set('expiry', expiry) | ||
return this | ||
} | ||
|
||
asMap() { | ||
return this.#map | ||
} | ||
} | ||
|
||
module.exports = { CookieFilter } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
class PartialCookie { | ||
#map = new Map() | ||
|
||
constructor(name, value, domain) { | ||
this.#map.set('name', name) | ||
this.#map.set('value', Object.fromEntries(value.asMap())) | ||
this.#map.set('domain', domain) | ||
} | ||
|
||
path(path) { | ||
this.#map.set('path', path) | ||
return this | ||
} | ||
|
||
size(size) { | ||
this.#map.set('size', size) | ||
return this | ||
} | ||
|
||
httpOnly(httpOnly) { | ||
this.#map.set('httpOnly', httpOnly) | ||
return this | ||
} | ||
|
||
secure(secure) { | ||
this.#map.set('secure', secure) | ||
return this | ||
} | ||
|
||
sameSite(sameSite) { | ||
this.#map.set('sameSite', sameSite) | ||
return this | ||
} | ||
|
||
expiry(expiry) { | ||
this.#map.set('expiry', expiry) | ||
return this | ||
} | ||
|
||
asMap() { | ||
return this.#map | ||
} | ||
} | ||
|
||
module.exports = { PartialCookie } |
69 changes: 69 additions & 0 deletions
69
javascript/node/selenium-webdriver/bidi/partitionDescriptor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
Type = { | ||
CONTEXT: 'context', | ||
STORAGE_KEY: 'storageKey', | ||
} | ||
|
||
class PartitionDescriptor { | ||
#type | ||
|
||
constructor(type) { | ||
this.#type = type | ||
} | ||
} | ||
|
||
class BrowsingContextPartitionDescriptor extends PartitionDescriptor { | ||
#context = null | ||
|
||
constructor(context) { | ||
super(Type.CONTEXT) | ||
this.#context = context | ||
} | ||
|
||
asMap() { | ||
const map = new Map() | ||
map.set('type', Type.CONTEXT) | ||
map.set('context', this.#context) | ||
return map | ||
} | ||
} | ||
|
||
class StorageKeyPartitionDescriptor extends PartitionDescriptor { | ||
#map = new Map() | ||
|
||
constructor() { | ||
super(Type.STORAGE_KEY) | ||
} | ||
|
||
userContext(userContext) { | ||
this.#map.set('userContext', userContext) | ||
return this | ||
} | ||
|
||
sourceOrigin(sourceOrigin) { | ||
this.#map.set('sourceOrigin', sourceOrigin) | ||
return this | ||
} | ||
|
||
asMap() { | ||
return this.#map | ||
} | ||
} | ||
|
||
module.exports = { BrowsingContextPartitionDescriptor, StorageKeyPartitionDescriptor } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
class PartitionKey { | ||
#userContext | ||
#sourceOrigin | ||
|
||
constructor(userContext, sourceOrigin) { | ||
this.#userContext = userContext | ||
this.#sourceOrigin = sourceOrigin | ||
} | ||
|
||
get userContext() { | ||
return this.#userContext | ||
} | ||
|
||
get sourceOrigin() { | ||
return this.#sourceOrigin | ||
} | ||
} | ||
|
||
module.exports = { PartitionKey } |
Oops, something went wrong.