aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormongolyy <mongolyy@gmail.com>2022-02-19 16:56:20 +0900
committerMasahiro FUJIMOTO <mfujimot@gmail.com>2022-03-12 21:36:02 +0900
commit33100df5d2ca3929ac971161fe5ec6d55bacf382 (patch)
tree4c30fded664d6873f3452e072d1de1682daf9455
parentadbd42a4e466e24bc462955b954224ae9961911f (diff)
downloadtranslated-content-33100df5d2ca3929ac971161fe5ec6d55bacf382.tar.gz
translated-content-33100df5d2ca3929ac971161fe5ec6d55bacf382.tar.bz2
translated-content-33100df5d2ca3929ac971161fe5ec6d55bacf382.zip
cookie storeと関連ページを翻訳
-rw-r--r--files/ja/web/api/cookiestore/change_event/index.md51
-rw-r--r--files/ja/web/api/cookiestore/delete/index.md66
-rw-r--r--files/ja/web/api/cookiestore/get/index.md93
-rw-r--r--files/ja/web/api/cookiestore/getall/index.md66
-rw-r--r--files/ja/web/api/cookiestore/index.md63
-rw-r--r--files/ja/web/api/cookiestore/set/index.md89
6 files changed, 428 insertions, 0 deletions
diff --git a/files/ja/web/api/cookiestore/change_event/index.md b/files/ja/web/api/cookiestore/change_event/index.md
new file mode 100644
index 0000000000..f28ed2ba69
--- /dev/null
+++ b/files/ja/web/api/cookiestore/change_event/index.md
@@ -0,0 +1,51 @@
+---
+title: 'CookieStore: change event'
+slug: Web/API/CookieStore/change_event
+tags:
+ - API
+ - Reference
+ - Event
+ - change
+ - onchange
+ - CookieStore
+browser-compat: api.CookieStore.change_event
+---
+{{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}
+
+任意のCookieに変更が加えられると、 {{domxref("CookieStore")}} オブジェクトで `change` イベントが発火します。
+
+## 構文
+
+イベント名は {{domxref("EventTarget.addEventListener", "addEventListener()")}} などのメソッドで使用したり、イベントハンドラープロパティで設定されます。
+
+```js
+cookieStore.addEventListener('change', event => { })
+
+cookieStore.onchange = event => { }
+```
+
+## 例
+
+Cookieが変更されたときに通知を受けるには、以下のように {{domxref("EventTarget.addEventListener", "addEventListener()")}} を使って `cookieStore` インスタンスにハンドラを追加することが可能です。
+
+```js
+cookieStore.addEventListener('change', function(event) {
+ console.log('1 change event');
+});
+```
+
+あるいは、 `CookieStore.onchange` イベントハンドラープロパティを使用して、 `change` イベントのハンドラを定義することもできます。
+
+```js
+cookieStore.onchange = function(event) {
+ console.log('1 change event');
+};
+```
+
+## 仕様
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}
diff --git a/files/ja/web/api/cookiestore/delete/index.md b/files/ja/web/api/cookiestore/delete/index.md
new file mode 100644
index 0000000000..9caf027501
--- /dev/null
+++ b/files/ja/web/api/cookiestore/delete/index.md
@@ -0,0 +1,66 @@
+---
+title: CookieStore.delete()
+slug: Web/API/CookieStore/delete
+tags:
+ - API
+ - Method
+ - Reference
+ - delete()
+ - CookieStore
+browser-compat: api.CookieStore.delete
+---
+{{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}
+
+domxref("CookieStore")}} インターフェースの **`delete()`** メソッドは、与えられた名前またはオプションオブジェクトを持つ Cookie を削除します(下記参照)。`delete()` メソッドは日付を過去のものに変更することでCookieを失効させます。
+
+## 構文
+
+```js
+var promise = cookieStore.delete(name);
+var promise = cookieStore.delete(options);
+```
+
+### 引数
+
+このメソッドは、以下のいずれかが必要です。
+
+- `name`
+ - : Cookie の名前が入っている {{domxref("USVString")}} です。
+- オプション
+
+ - : オブジェクトは次のものを含みます。
+
+ - `name`
+ - : Cookie の名前が入っている {{domxref("USVString")}} です。
+ - `url`{{Optional_Inline}}
+ - : Cookie の URL が入っている {{domxref("USVString")}} です。
+ - `path`{{Optional_Inline}}
+ - : パスを含む {{domxref("USVString")}} です。
+
+> **Note:** `url` オプションは、特定の URL をスコープとした Cookie の変更を可能にします。サービスワーカーは、自分のスコープ下にある任意の URL に送信される Cookie を取得できます。ドキュメントからは現在の URL の Cookie しか取得できないので、ドキュメントコンテキストで有効な URL はドキュメントの URL のみとなります。
+
+### 返値
+
+削除が完了すると {{jsxref("Undefined")}} に解決される {{jsxref("Promise")}} です。
+
+### 例外
+
+- {{jsxref("TypeError")}}
+ - : 与えられた `name` や `options` で表される Cookie の削除に失敗した場合にスローされます。
+
+## 例
+
+この例では、`delete()` メソッドに名前を渡すことで、 Cookie を削除しています。
+
+```js
+let result = cookieStore.delete('cookie1');
+console.log(result);
+```
+
+## 仕様
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}
diff --git a/files/ja/web/api/cookiestore/get/index.md b/files/ja/web/api/cookiestore/get/index.md
new file mode 100644
index 0000000000..cbefeb0b52
--- /dev/null
+++ b/files/ja/web/api/cookiestore/get/index.md
@@ -0,0 +1,93 @@
+---
+title: CookieStore.get()
+slug: Web/API/CookieStore/get
+tags:
+ - API
+ - Method
+ - Reference
+ - get()
+ - CookieStore
+browser-compat: api.CookieStore.get
+---
+{{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}
+
+{{Domxref("CookieStore")}} インターフェイスの **`get()`** メソッドは、与えられた名前またはオプションオブジェクトを持つ一つの Cookie を返します(下記参照)。このメソッドは渡されたパラメータに最初にマッチする Cookie を返します。
+
+## 構文
+
+```js
+var cookie = CookieStore.get(name);
+var cookie = CookieStore.get(options);
+```
+
+### 引数
+
+このメソッドは、以下のいずれかが必要です。
+
+- `name`
+ - : Cookie の名前が入っている {{domxref("USVString")}} です。
+- オプション
+
+ - : オブジェクトは次のものを含みます。
+
+ - `name`
+ - : Cookie の名前が入っている {{domxref("USVString")}} です。
+ - `url`
+ - : Cookie の URL が入っている {{domxref("USVString")}} です。
+
+> **Note:** `url` オプションは、特定の URL をスコープとした Cookie の変更を可能にします。サービスワーカーは、自分のスコープ下にある任意の URL に送信される Cookie を取得できます。ドキュメントからは現在の URL の Cookie しか取得できないので、ドキュメントコンテキストで有効な URL はドキュメントの URL のみとなります。
+
+### 返値
+
+与えられた名前またはオプションに一致する最初の Cookie を含むオブジェクトに解決される {{jsxref("Promise")}} です。このオブジェクトは以下のプロパティを含んでいます。
+
+- `name`
+ - : Cookie の名前を含む {{domxref("USVString")}} です。
+- `value`
+ - : Cookie の値を含む {{domxref("USVString")}} です。
+- `domain`
+ - : Cookie のドメインを含む {{domxref("USVString")}} です。
+- `path`
+ - : Cookie のパスを含む {{domxref("USVString")}} です。
+- `expires`
+ - : Cookie の有効期限を含む {{domxref("DOMTimeStamp")}} です。
+- `secure`
+ - : Cookie を安全なコンテキストでのみ使用するかどうかを示す {{jsxref("boolean")}} です。
+- `sameSite`
+
+ - : 以下の [SameSite](/ja/docs/Web/HTTP/Headers/Set-Cookie/SameSite) のいずれかの値です。
+
+ - `"strict"`
+ - : Cookie は、ファーストパーティのコンテキストでのみ送信され、サードパーティのウェブサイトによるリクエストと一緒に送信されることはありません
+ - `"lax"`
+ - : Cookie は、通常のクロスサイト・サブクエスト(例えば、画像やフレームをサードパーティのサイトにロードするため)には送信されませんが、ユーザーが元のサイト内を移動しているとき(すなわち、リンクをたどっているとき)には送信されます。
+ - `"none"`
+ - : クッキーは、すべてのコンテキストで送信されます。
+
+ > **Note:** SameSite cookies の詳細については、 [SameSite cookies explained](https://web.dev/samesite-cookies-explained/) をご覧ください。
+
+### 例外
+
+- {{jsxref("TypeError")}}
+ - : 与えられた `name` や `options` で表される Cookie の取得に失敗した場合にスローされます。
+
+## 例
+
+この例では、"cookie1" という名前の Cookie を返します。もし Cookie が見つかれば、プロミスの結果は一つの Cookie の詳細を含むオブジェクトになります。
+
+```js
+let cookie = cookieStore.get('cookie1');
+if (cookie) {
+ console.log(cookie);
+} else {
+ console.log('Cookie not found');
+}
+```
+
+## 仕様
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}
diff --git a/files/ja/web/api/cookiestore/getall/index.md b/files/ja/web/api/cookiestore/getall/index.md
new file mode 100644
index 0000000000..d72ee9315c
--- /dev/null
+++ b/files/ja/web/api/cookiestore/getall/index.md
@@ -0,0 +1,66 @@
+---
+title: CookieStore.getAll()
+slug: Web/API/CookieStore/getAll
+tags:
+ - API
+ - Method
+ - Reference
+ - getAll()
+ - CookieStore
+browser-compat: api.CookieStore.getAll
+---
+{{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}
+
+{{domxref("CookieStore")}} インターフェイスの **`getAll()`** メソッドは、渡された名前またはオプションに一致する Cookie のリストを返します。パラメータを何も渡さなければ、現在のコンテキストのすべての Cookie を返します。
+
+## 構文
+
+```js
+var list = cookieStore.getAll(name);
+var list = cookieStore.getAll(options);
+```
+
+### 引数
+
+- `name`{{Optional_Inline}}
+ - : Cookie の名前が入っている {{domxref("USVString")}} です。
+- `options`{{Optional_Inline}}
+
+ - : An object containing:
+
+ - `name`
+ - : Cookie の名前が入っている {{domxref("USVString")}} です。
+ - `url`
+ - : Cookie の URL が入っている {{domxref("USVString")}} です。
+
+> **Note:** `url` オプションは、特定の URL をスコープとした Cookie の変更を可能にします。サービスワーカーは、自分のスコープ下にある任意の URL に送信される Cookie を取得できます。ドキュメントからは現在の URL の Cookie しか取得できないので、ドキュメントコンテキストで有効な URL はドキュメントの URL のみとなります。
+
+### 返値
+
+与えられた名前またはオプションの Cookie のリストに解決される {{jsxref("Promise")}} です。
+
+### 例外
+
+- {{jsxref("TypeError")}}
+ - : 与えられた `name` や `options` で表される Cookie の取得に失敗した場合にスローされます。
+
+## 例
+
+この例では、引数無しで `getAll()` を使用しています。このコンテキストのすべての Cookie をオブジェクトの配列として返します。
+
+```js
+let cookies = cookieStore.getAll();
+if (cookies) {
+ console.log(cookies);
+} else {
+ console.log('Cookie not found');
+}
+```
+
+## 仕様
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}
diff --git a/files/ja/web/api/cookiestore/index.md b/files/ja/web/api/cookiestore/index.md
new file mode 100644
index 0000000000..40d6a5c589
--- /dev/null
+++ b/files/ja/web/api/cookiestore/index.md
@@ -0,0 +1,63 @@
+---
+title: CookieStore
+slug: Web/API/CookieStore
+tags:
+ - API
+ - Interface
+ - Reference
+ - CookieStore
+browser-compat: api.CookieStore
+---
+{{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}
+
+{{domxref('Cookie Store API')}} のインターフェイスである **`CookieStore`** は、ページまたはサービスワーカーから非同期にCookieを取得、設定するためのメソッドを提供します。
+
+`CookieStore` は {{domxref("Window")}} or {{domxref("ServiceWorkerGlobalScope")}} コンテキスト内のグローバスコープの属性を介してアクセスされます。そのため、コンストラクタはありません。
+
+{{InheritanceDiagram}}
+
+## メソッド
+
+- {{domxref("CookieStore.delete()")}}
+ - : `delete()` メソッドは与えられた名前またはオプションオブジェクトを持つCookieを削除します。削除が完了すると解決される {{jsxref("Promise")}} が返されます。
+- {{domxref("CookieStore.get()")}}
+ - : `get()` メソッドは与えられた名前またはオプションオブジェクトで一つのCookieを取得します。一つのCookieの詳細に解決される {{jsxref("Promise")}} を返します。
+- {{domxref("CookieStore.getAll()")}}
+ - : `getAll()` メソッドはマッチするすべてのCookieを取得します。Cookieのリストに解決される {{jsxref("Promise")}} を返します。
+- {{domxref("CookieStore.set()")}}
+ - : `set()` メソッドは与えられた名前と値またはオプションオブジェクトをCookieに設定し、Cookieが設定されると解決される {{jsxref("Promise")}} を返します。
+
+## イベント
+
+- {{domxref("CookieStore.change_event")}}
+ - : `change` イベントは、任意のCookieに変更が加えられたときに発生します。
+
+## 例
+
+この例では、Cookieを設定し、操作が成功したか失敗したかのフィードバックをコンソールに書き込んでいます。
+
+```js
+const day = 24 * 60 * 60 * 1000;
+cookieStore.set({
+ name: "cookie1",
+ value: "cookie1-value",
+ expires: Date.now() + day,
+ domain: "example.com"
+})
+.then(
+ function() {
+ console.log("It worked!");
+ },
+ function(reason) {
+ console.error("It failed: ", reason);
+ }
+);
+```
+
+## 仕様
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}
diff --git a/files/ja/web/api/cookiestore/set/index.md b/files/ja/web/api/cookiestore/set/index.md
new file mode 100644
index 0000000000..8fa58a7303
--- /dev/null
+++ b/files/ja/web/api/cookiestore/set/index.md
@@ -0,0 +1,89 @@
+---
+title: CookieStore.set()
+slug: Web/API/CookieStore/set
+tags:
+ - API
+ - Method
+ - Reference
+ - set()
+ - CookieStore
+browser-compat: api.CookieStore.set
+---
+{{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}
+
+{{domxref("CookieStore")}} インターフェイスの **`getAll()`** メソッドは、渡された名前またはオプションに一致する Cookie のリストを返します。引数を何も渡さなければ、現在のコンテキストのすべての Cookie を返します。
+
+## 構文
+
+```js
+var promise = cookieStore.set(name,value);
+var promise = cookieStore.set(options);
+```
+
+### 引数
+
+このメソッドは、以下のいずれかが必要です。
+
+- `name`
+ - : Cookie の名前が入っている {{domxref("USVString")}} です。
+- `value`
+ - : Cookie の値が入っている {{domxref("USVString")}} です。
+- オプション
+
+ - : オブジェクトは次のものを含みます。
+
+ - `name`
+ - : Cookie の名前が入っている {{domxref("USVString")}} です。
+ - `value`
+ - : Cookie の値が入っている {{domxref("USVString")}} です。
+ - `expires`{{Optional_Inline}}
+ - : Cookie の有効期限を含む {{domxref("DOMTimeStamp")}} です。
+ - `domain`{{Optional_Inline}}
+ - : Cookie のドメインを含む {{domxref("USVString")}} です。
+ - `path`{{Optional_Inline}}
+ - : Cookie のパスを含む {{domxref("USVString")}} です。
+ - `sameSite`{{Optional_Inline}}
+
+ - : 以下の [SameSite](/ja/docs/Web/HTTP/Headers/Set-Cookie/SameSite) のいずれかの値です。
+
+ - `"strict"`
+ - : Cookie は、ファーストパーティのコンテキストでのみ送信され、サードパーティのウェブサイトによるリクエストと一緒に送信されることはありません
+ - `"lax"`
+ - : Cookie は、通常のクロスサイト・サブクエスト(例えば、画像やフレームをサードパーティのサイトにロードするため)には送信されませんが、ユーザーが元のサイト内を移動しているとき(すなわち、リンクをたどっているとき)には送信されます。
+ - `"none"`
+ - : クッキーは、すべてのコンテキストで送信されます。
+
+ > **Note:** SameSite cookies の詳細については、 [SameSite cookies explained](https://web.dev/samesite-cookies-explained/) をご覧ください。
+
+### 返値
+
+Cookie の設定が完了すると {{jsxref("Undefined")}} に解決される {{jsxref("Promise")}} です。
+
+### 例外
+
+- {{jsxref("TypeError")}}
+ - : 与えられた値での Cookie の設定に失敗した場合にスローされます。
+- {{domxref("DOMException")}} `SecurityError`
+ - : オリジンがURLに {{glossary("serialize")}} されない場合にスローされます。
+
+## 例
+
+次の例では `name`、`value`、`expires`、`domain` を持つオブジェクトを渡して Cookie を設定します。
+
+```js
+const day = 24 * 60 * 60 * 1000;
+cookieStore.set({
+ name: "cookie1",
+ value: "cookie1-value",
+ expires: Date.now() + day,
+ domain: "example.com"
+});
+```
+
+## 仕様
+
+{{Specifications}}
+
+## ブラウザーの互換性
+
+{{Compat}}