[36] [DFN[[CODE(JS)@en[[[window.opener]]]]]] は、[CODE(JS)@en[[[window.open]]]]
で開いた[[閲覧文脈]]内の[[スクリプト]]から、元の[[閲覧文脈]]へとアクセスするための[[特性]]です。

* 仕様書

[REFS[
- [13] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2015-11-12 17:26:47 +09:00]] 版) <https://html.spec.whatwg.org/#opener-browsing-context>
- [16] '''[CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2015-11-12 17:26:47 +09:00]] 版) <https://html.spec.whatwg.org/#dom-opener>'''
- [8] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2015-11-12 17:26:47 +09:00]] 版) <https://html.spec.whatwg.org/#link-type-noopener>
- [37] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2015-11-12 17:26:47 +09:00]] 版) <https://html.spec.whatwg.org/#dom-open>
]REFS]

* [CODE(JS)@en[window.opener]] (DOM)

[17] [CODE(DOMi)@en[[[Window]]]] [[インターフェイス]]の
[DFN[[CODE(DOMa)@en[opener]]]] [[IDL属性]]の[[取得器]]は、
次のようにしなければ[MUST[なりません]] [SRC[>>16]]。

[FIG(steps)[
= [58] [VAR[現在]]を、
[[文脈オブジェクト]]の[F[閲覧文脈]]に設定します。
= [69] 
[VAR[現在]]が [CODE[null]] か、
[VAR[現在]]が[F[廃除済み]]か、
[VAR[現在]]の[F[opener閲覧文脈]]が [CODE[null]] の場合、
== [62] [CODE[null]] を返します。
= [59] それ以外の場合、
== [18] [VAR[現在]]の[F[opener閲覧文脈]]の
[F[[CODE(DOMi)@en[WindowProxy]]]] を返します。
]FIG]

[26] [CODE(DOMi)@en[Window]] [[インターフェイス]]の
[CODE[opener]] [[IDL属性]]の[[設定器]]は、
[VAR[指定値]]について、次のようにしなければ[MUST[なりません]] [SRC[>>16]]。

[FIG(steps)[
= [19] [VAR[指定値]]が [CODE[null]] の場合、
== [60] [[文脈オブジェクト]]の[F[閲覧文脈]]が
[CODE[null]] で''ない''場合、
=== [20] [[文脈オブジェクト]]の[F[閲覧文脈]]について[[廃除]]します。
= [29] それ以外の場合、
== [30] [CODE[OrdinaryDefineOwnProperty]] を実行します。
[FIG(list members)[

: [F[オブジェクト]] : [[文脈オブジェクト]]
:[[property key]]: [CODE[opener]]
:[[Property Descriptor]]:
[FIG(list members)[
:[F(ss)[Value]]:  [VAR[指定値]]
:[F(ss)[Writable]]: [[真]]
:[F(ss)[Enumerable]]: [[真]]
:[F(ss)[Configurable]]: [[真]]
]FIG]

]FIG]
[[例外]]が[[投げ]]られたら、[[再び投げ]]ます。

]FIG]

;; [35] [CODE[[[opener]]]] という名前の通常の [[JavaScript]]
の[[変数]]が使われることがあるため、値を一度設定したら [[IDL属性]]ではなくなる、
というかなり特殊な[[設定器]]となっています。

-*-*-

[15] [[補助閲覧文脈]]は、
[F[[[opener閲覧文脈]]]]と[DFN[[F[[RUBYB[[[廃除済み]]]@en[disowned]]]]]]
(初期値は[[偽]]) を持ちます [SRC[>>13]]。

[14] [DFN[[RUBYB[opener閲覧文脈]@en[opener browsing context]]]]は、
[[補助閲覧文脈]]が作成された元の[[閲覧文脈]]です [SRC[>>13]]。

[31] [[opener閲覧文脈]]は、[[直接到達可能閲覧文脈]]かどうかや
[[familiar with]] かどうかの決定に影響します。

[32] [F[[[opener閲覧文脈]]]]は、[F[[[作成子閲覧文脈]]]]ともなることがあります。

[33] ある[[閲覧文脈]]の[F[[[opener閲覧文脈]]]]という関係は、
[DFN[廃除]] ([DFN[[[disown its opener]]]]) [SRC[>>16]] されることがあります。
これは、[[スクリプト]]から [CODE(JS)@en[[[window.opener]]]]
を通して [[opener閲覧文脈]]へのアクセスをできなくする(なる)ことをいいます。

;; 他の[[変数]]等で依然としてアクセス可能な場合もありますが、
[[opener閲覧文脈]]ではなくなります。

[34] disown されるのは、次の場合です。

- [CODE(JS)@en[[[window.opener]]]] に値を設定した場合 ([CODE(JS)@en[[[window.opener]] = [[window.opener]]]] も含みます)。
- [CODE(HTML)@en[[[rel=noreferrer]]]] が適用される場合 ([[ハイパーリンクをたどる]]処理)。
- [CODE(HTML)@en[[[rel=noopener]]]] が適用される場合 ([[ハイパーリンクをたどる]]処理)。
- [CODE(JS)@en[[[window.open]]]] の機能 [CODE(HTML)@en[[[noopener]]]] が指定された場合。
- [[サービスワーカー]]下の[[非保安文脈]]から[[保安文脈]]への [[navigate]]

* リンク型 [CODE(HTML)@en[noopener]]

[9] [[リンク型]] [DFN[[CODE(HTML)@en[[[noopener]]]]]] は、
新しい[[閲覧文脈]]を開いた時に [CODE(JS)@en[[[window.opener]]]]
を [[null]] とするべきことを示します。

[10] [CODE(HTML)@en[[[noopener]]]] は、 [CODE(HTMLe)@en[[[a]]]] [[要素]]や
[CODE(HTMLe)@en[[[area]]]] [[要素]]の [CODE(HTMLa)@en[[[rel]]]]
[[属性]]で使うことができます [SRC[>>8]]。

[11] 本[[リンク型]]は[[ハイパーリンク]]を作成するものではなく、注釈となるもの
([[hypertext annotation]]) です。 (他に[[リンク型]]を作成する[[ハイパーリンク]]が無い時は、
暗示的に作成される[[ハイパーリンク]]を注釈付けするものです。) [SRC[>>8]]

;; [12] この性質は [CODE(HTML)@en[[[noreferrer]]]] と似ています。

* [CODE(JS)@en[window.open]] の機能 [CODE[noopener]]

[38] [CODE(JS)@en[[[window.opener]]]] の第3引数 [VAR[[[features]]]]
の字句 [DFN[[CODE[[[noopener]]]]]] [SRC[>>37]] は、新しい[[閲覧文脈]]を開いた時、
その関係を切ることを求めるものです。

[39] これが指定された場合、新しい[[閲覧文脈]]側の [CODE(JS)@en[[[window.opener]]]]
は [[null]] となります。 [CODE(JS)@en[[[window.open]]]] は [[null]]
を返し、新しい[[閲覧文脈]]を返しません。

* 歴史

[1] [CITE@en[Web Applications 1.0 r7941     Example window.opener cross-origin.]]
( ([TIME[2013-06-08 07:55:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7940&to=7941>

[2] [CITE@en[Bug 21946 – Ignoring non-null values of opener does not seem to be web-compatible]]
( ([TIME[2013-06-09 22:22:16 +09:00]] 版))
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=21946>

[3] [CITE@en[Web Applications 1.0 r8235     Try to make window.opener more compatible]]
( ([TIME[2013-10-23 03:15:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8234&to=8235>

[4] [CITE[''''''[''''''whatwg'''''']'''''' Effect on window.opener when navigating an existing window using window.open]]
( ([TIME[2014-04-02 20:17:18 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2014-April/126955.html>

[5] [CITE@en[Web Applications 1.0 r8652     Turns out window.opener is set to all kinds of crazy things and we shouldn't fire TypeError for them]]
( ([TIME[2014-05-31 03:34:00 +09:00]] 版))
<http://html5.org/r/8652>

[6] [CITE[IRC logs: freenode / #whatwg / 20151105]]
([TIME[2015-11-06 17:57:39 +09:00]] 版)
<http://krijnhoetmer.nl/irc-logs/whatwg/20151105#l-441>

[7] [CITE@en[Add a 'noopener' <link rel> keyword and window feature · whatwg/html@2992ea9]] ([TIME[2015-11-12 21:22:48 +09:00]] 版) <https://github.com/whatwg/html/commit/2992ea921bc75e44157451a37a807a8ce0b9a884>

[211] [CITE@en[Add a 'noopener' link attribute by mikewest · Pull Request #290 · whatwg/html]] ([TIME[2015-11-12 22:14:09 +09:00]] 版) <https://github.com/whatwg/html/pull/290>

[40] [CITE@en[Popups from non-secure contexts now require `noopener` to be consider… · w3c/webappsec-secure-contexts@b062415]]
([TIME[2015-11-13 11:56:10 +09:00]] 版)
<https://github.com/w3c/webappsec-secure-contexts/commit/b062415fb3b1213b37ecce5c63e70f48888c6f8d>

[41] [CITE@en[28821 – add rel=newcontext]]
([TIME[2016-03-09 15:23:18 +09:00]] 版)
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=28821>

[42] [CITE[About rel=noopener]]
([TIME[2016-03-16 19:28:03 +09:00]] 版)
<https://mathiasbynens.github.io/rel-noopener/>

[43] [CITE@en[Fixing some links and cleaning up lists.]]
([[mikewest]]著, [TIME[2016-07-15 22:00:54 +09:00]])
<https://github.com/w3c/webappsec-secure-contexts/commit/5f36532e8909c8bf72daa431724b6372bc5366ab>

[44] [CITE@en[Improve navigate for service worker hooks]]
([[jungkees]]著, [TIME[2016-10-24 20:32:35 +09:00]])
<https://github.com/whatwg/html/commit/2b93f9ec35b152e58d3e181bea8c45d789bac949>

[FIG(quote)[
[FIGCAPTION[
[45] [CITE[Release Notes for Safari Technology Preview 17 | WebKit]]
( ([TIME[2016-11-10 10:08:39 +09:00]]))
<https://webkit.org/blog/7071/release-notes-for-safari-technology-preview-17/>
]FIGCAPTION]

> Implemented rel=noopener (r207840)

]FIG]


[46] [CITE@en[Clarify rel=noopener & "disown opener" effects]]
([[sideshowbarker]]著, [TIME[2016-11-06 19:39:31 +09:00]])
<https://github.com/whatwg/html/commit/b2762db3980154c016a07752fd0feebb0f6581d5>

[47] [CITE[About rel=noopener]]
([TIME[2016-11-30 23:11:49 +09:00]])
<https://mathiasbynens.github.io/rel-noopener/>

[48] [CITE@en[Stubbing out 'disown-opener'.]]
([[mikewest]]著, [TIME[2016-07-25 23:58:00 +09:00]])
<https://github.com/w3c/webappsec-csp/commit/68330f35ba42ffc426aee26715968d7a2ee203c6>


[49] [CITE@en[Breaking the `opener` relationship.]]
([[Mike West]]著, [TIME[2017-04-27 19:57:24 +09:00]])
<https://lists.w3.org/Archives/Public/public-webappsec/2017Apr/0071.html>

[50] [CITE@en[Mark a few things as WIP.]]
([[mikewest]]著, [TIME[2017-08-04 18:47:10 +09:00]])
<https://github.com/w3c/webappsec-csp/commit/eff9c9c3277e108d243d44fa21924f532b6b1a87>

[51] [CITE@en[Make noopener stop the copying of session storage]]
([[mystor]]著, [TIME[2017-09-06 06:56:03 +09:00]])
<https://github.com/whatwg/html/commit/a68a1f712b641981d7367d78758596b21a04521c>

[52] [CITE@en[1372662 - Don't copy SessionStore when creating a window with noopener]]
([TIME[2017-09-10 20:52:36 +09:00]])
<https://bugzilla.mozilla.org/show_bug.cgi?id=1372662>

[53] [CITE@en[Mention `sessionStorage` copying in logic for creating auxiliary browsing contexts · Issue #2681 · whatwg/html]]
([TIME[2017-09-10 20:52:57 +09:00]])
<https://github.com/whatwg/html/issues/2681>

[54] [CITE@en[Mention sessionStorage copying in logic for creating a new browsing context by mystor · Pull Request #2832 · whatwg/html]]
([TIME[2017-09-10 20:53:07 +09:00]])
<https://github.com/whatwg/html/pull/2832>

[55] [CITE@en[Should opener be taken into consideration when determining if a context is secure? · Issue #42 · w3c/webappsec-secure-contexts]]
([TIME[2017-10-19 12:26:44 +09:00]])
<https://github.com/w3c/webappsec-secure-contexts/issues/42>

[56] [CITE@en["On setting, if the new value is null then the c..." · Issue #3351 · whatwg/html]]
([TIME[2018-01-17 15:54:46 +09:00]])
<https://github.com/whatwg/html/issues/3351>

[57] [CITE@en[Editorial: cleanup window.opener]]
([[annevk]]著, [TIME[2018-02-09 02:24:50 +09:00]])
<https://github.com/whatwg/html/commit/15317c7a58040af294510e7511c0512a19083ffb>

[21] [CITE@en[Editorial: cleanup window.opener by annevk · Pull Request #3448 · whatwg/html]]
([TIME[2018-02-11 18:26:15 +09:00]])
<https://github.com/whatwg/html/pull/3448>

[22] [CITE@en[Editorial: cleanup window.opener by annevk · Pull Request #3448 · whatwg/html]]
([TIME[2018-02-11 18:27:11 +09:00]])
<https://github.com/whatwg/html/pull/3448>

[23] [CITE@en[Fix #313: make disowning disown the opener browsing context too by annevk · Pull Request #323 · whatwg/html]]
([TIME[2018-02-11 18:28:17 +09:00]])
<https://github.com/whatwg/html/pull/323>

[24] [CITE@en[Meltdown/Spectre  |  Web  |  Google Developers]]
([TIME[2018-02-08 00:05:08 +09:00]])
<https://developers.google.com/web/updates/2018/02/meltdown-spectre>

[25] [CITE@en[Editorial: fix confusing phrasing for opener setter]]
([[domenic]]著, [TIME[2018-08-16 00:02:57 +09:00]])
<https://github.com/whatwg/html/commit/fefb8792a278bc2568a038bb1135862921ea365e>

[27] [CITE@en["opener" setter says to return things, but setters can't return stuff · Issue #3904 · whatwg/html]]
([TIME[2018-08-16 15:41:50 +09:00]])
<https://github.com/whatwg/html/issues/3904>

[28] [CITE@en[Editorial: fix confusing phrasing for opener setter by domenic · Pull Request #3916 · whatwg/html]]
([TIME[2018-08-16 15:42:25 +09:00]])
<https://github.com/whatwg/html/pull/3916>

[63] [CITE@en[Removed disown-opener (#327)]]
([[andypaicu]]著, [TIME[2018-09-13 01:27:43 +09:00]])
<https://github.com/w3c/webappsec-csp/commit/52b71625bd6ed7123615e9d7c159f9ad805a5ba7>

[64] [CITE@en[Removed disown-opener as it will not make it into CSP3 by andypaicu · Pull Request #327 · w3c/webappsec-csp]]
([TIME[2018-10-17 22:06:34 +09:00]])
<https://github.com/w3c/webappsec-csp/pull/327>

[65] [CITE@en[CSP3: Add something along the lines of `disown-window-owner`. · Issue #139 · w3c/webappsec]]
([TIME[2018-10-17 22:07:11 +09:00]])
<https://github.com/w3c/webappsec/issues/139>

[FIG(quote)[
[FIGCAPTION[
[66] [CITE@en[Safari 12.1 Release Notes | Apple Developer Documentation]]
([TIME[2019-02-10 12:06:38 +09:00]])
<https://developer.apple.com/documentation/safari_release_notes/safari_12_1_release_notes>
]FIGCAPTION]

> Updated the link behavior for "target=_blank" to include rel="noopener" implicitly.

]FIG]


[67] [CITE@en[Consider not setting browsing context name when noopener/noreferrer are used · Issue #4314 · whatwg/html]]
([TIME[2019-02-16 18:50:03 +09:00]])
<https://github.com/whatwg/html/issues/4314>

[68] [CITE@en[Define Window's opener when there's no browsing context]]
([[annevk]]著, [TIME[2019-03-04 22:48:56 +09:00]])
<https://github.com/whatwg/html/commit/7c9a8c0a382cfc2a0d193daff2f2fb95beef5a0b>

[61] [CITE@en[Define Window's opener when there's no browsing context by annevk · Pull Request #4379 · whatwg/html]]
([TIME[2019-08-23 14:25:15 +09:00]])
<https://github.com/whatwg/html/pull/4379>

[70] [CITE@en[Support noreferrer for window.open()]]
([[annevk]]著, [TIME[2019-02-12 21:54:42 +09:00]])
<https://github.com/whatwg/html/commit/a9a7944f20ec9223c252578db3e8bf870bca5718>

[71] [CITE@en[Editorial: inline noreferrer processing model]]
([[annevk]]著, [TIME[2019-02-12 21:54:42 +09:00]])
<https://github.com/whatwg/html/commit/f47773d25a7b1a3a03c1047bbc4037d08639cf9b>

[72] [CITE@en[noopener window.open feature seems pretty broken as implemented in browsers · Issue #1902 · whatwg/html]]
([TIME[2021-07-02T10:08:24.000Z]])
<https://github.com/whatwg/html/issues/1902>

[73] [CITE@en[CSP3: Add something along the lines of `disown-window-owner`. · Issue #139 · w3c/webappsec]]
([TIME[2021-07-02T10:11:49.000Z]])
<https://github.com/w3c/webappsec/issues/139>

[74] [CITE@en[Links to Unrelated Browsing Contexts - WHATWG Wiki]]
([TIME[2021-06-19T18:01:41.000Z]], [TIME[2021-07-02T10:12:17.042Z]])
<https://wiki.whatwg.org/wiki/Links_to_Unrelated_Browsing_Contexts>

[75] [CITE@en[69267 - Provide an explicit way to suggest opening a link in a new process]]
([TIME[2021-07-02T10:13:22.000Z]])
<https://bugs.chromium.org/p/chromium/issues/detail?id=69267>

[76] [CITE@en[Deprecate rel="noopener" · Issue #2119 · whatwg/html]]
([TIME[2021-07-02T10:14:34.000Z]])
<https://github.com/whatwg/html/issues/2119>

[77] [CITE@en[Remove noopener from tokenizedFeatures by annevk · Pull Request #3297 · whatwg/html]]
([TIME[2021-07-02T10:30:34.000Z]])
<https://github.com/whatwg/html/pull/3297>