Location.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. /*
  2. * Copyright (c) 2020-2023, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include <AK/String.h>
  8. #include <AK/StringBuilder.h>
  9. #include <AK/URLParser.h>
  10. #include <LibJS/Heap/MarkedVector.h>
  11. #include <LibJS/Runtime/Completion.h>
  12. #include <LibJS/Runtime/PropertyDescriptor.h>
  13. #include <LibJS/Runtime/PropertyKey.h>
  14. #include <LibWeb/Bindings/LocationPrototype.h>
  15. #include <LibWeb/DOM/Document.h>
  16. #include <LibWeb/HTML/CrossOrigin/AbstractOperations.h>
  17. #include <LibWeb/HTML/Location.h>
  18. #include <LibWeb/HTML/Window.h>
  19. #include <LibWeb/WebIDL/DOMException.h>
  20. namespace Web::HTML {
  21. // https://html.spec.whatwg.org/multipage/history.html#the-location-interface
  22. Location::Location(JS::Realm& realm)
  23. : PlatformObject(realm)
  24. {
  25. }
  26. Location::~Location() = default;
  27. void Location::visit_edges(Cell::Visitor& visitor)
  28. {
  29. Base::visit_edges(visitor);
  30. for (auto& property : m_default_properties)
  31. visitor.visit(property);
  32. }
  33. void Location::initialize(JS::Realm& realm)
  34. {
  35. Base::initialize(realm);
  36. set_prototype(&Bindings::ensure_web_prototype<Bindings::LocationPrototype>(realm, "Location"));
  37. // FIXME: Implement steps 2.-4.
  38. // 5. Set the value of the [[DefaultProperties]] internal slot of location to location.[[OwnPropertyKeys]]().
  39. // NOTE: In LibWeb this happens before the ESO is set up, so we must avoid location's custom [[OwnPropertyKeys]].
  40. m_default_properties.extend(MUST(Object::internal_own_property_keys()));
  41. }
  42. // https://html.spec.whatwg.org/multipage/history.html#relevant-document
  43. JS::GCPtr<DOM::Document> Location::relevant_document() const
  44. {
  45. // A Location object has an associated relevant Document, which is this Location object's
  46. // relevant global object's browsing context's active document, if this Location object's
  47. // relevant global object's browsing context is non-null, and null otherwise.
  48. auto* browsing_context = verify_cast<HTML::Window>(HTML::relevant_global_object(*this)).browsing_context();
  49. return browsing_context ? browsing_context->active_document() : nullptr;
  50. }
  51. // https://html.spec.whatwg.org/multipage/history.html#concept-location-url
  52. AK::URL Location::url() const
  53. {
  54. // A Location object has an associated url, which is this Location object's relevant Document's URL,
  55. // if this Location object's relevant Document is non-null, and about:blank otherwise.
  56. auto const relevant_document = this->relevant_document();
  57. return relevant_document ? relevant_document->url() : "about:blank"sv;
  58. }
  59. // https://html.spec.whatwg.org/multipage/history.html#dom-location-href
  60. WebIDL::ExceptionOr<String> Location::href() const
  61. {
  62. auto& vm = this->vm();
  63. // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
  64. auto const relevant_document = this->relevant_document();
  65. if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
  66. return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
  67. // 2. Return this's url, serialized.
  68. return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url().serialize()));
  69. }
  70. // https://html.spec.whatwg.org/multipage/history.html#the-location-interface:dom-location-href-2
  71. WebIDL::ExceptionOr<void> Location::set_href(String const& new_href)
  72. {
  73. auto& vm = this->vm();
  74. auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
  75. // 1. If this's relevant Document is null, then return.
  76. auto const relevant_document = this->relevant_document();
  77. if (!relevant_document)
  78. return {};
  79. // 2. Parse the given value relative to the entry settings object. If that failed, throw a TypeError exception.
  80. auto href_url = window.associated_document().parse_url(new_href.to_deprecated_string());
  81. if (!href_url.is_valid())
  82. return vm.throw_completion<JS::URIError>(TRY_OR_THROW_OOM(vm, String::formatted("Invalid URL '{}'", new_href)));
  83. // 3. Location-object navigate given the resulting URL record.
  84. window.did_set_location_href({}, href_url);
  85. return {};
  86. }
  87. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location-origin
  88. WebIDL::ExceptionOr<String> Location::origin() const
  89. {
  90. auto& vm = this->vm();
  91. // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
  92. auto const relevant_document = this->relevant_document();
  93. if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
  94. return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
  95. // 2. Return the serialization of this's url's origin.
  96. return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url().serialize_origin()));
  97. }
  98. // https://html.spec.whatwg.org/multipage/history.html#dom-location-protocol
  99. WebIDL::ExceptionOr<String> Location::protocol() const
  100. {
  101. auto& vm = this->vm();
  102. // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
  103. auto const relevant_document = this->relevant_document();
  104. if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
  105. return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
  106. // 2. Return this's url's scheme, followed by ":".
  107. return TRY_OR_THROW_OOM(vm, String::formatted("{}:", url().scheme()));
  108. }
  109. WebIDL::ExceptionOr<void> Location::set_protocol(String const&)
  110. {
  111. auto& vm = this->vm();
  112. return vm.throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "Location.protocol setter");
  113. }
  114. // https://html.spec.whatwg.org/multipage/history.html#dom-location-host
  115. WebIDL::ExceptionOr<String> Location::host() const
  116. {
  117. auto& vm = this->vm();
  118. // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
  119. auto const relevant_document = this->relevant_document();
  120. if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
  121. return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
  122. // 2. Let url be this's url.
  123. auto url = this->url();
  124. // 3. If url's host is null, return the empty string.
  125. if (url.host().has<Empty>())
  126. return String {};
  127. // 4. If url's port is null, return url's host, serialized.
  128. if (!url.port().has_value())
  129. return TRY_OR_THROW_OOM(vm, url.serialized_host());
  130. // 5. Return url's host, serialized, followed by ":" and url's port, serialized.
  131. return TRY_OR_THROW_OOM(vm, String::formatted("{}:{}", TRY_OR_THROW_OOM(vm, url.serialized_host()), *url.port()));
  132. }
  133. WebIDL::ExceptionOr<void> Location::set_host(String const&)
  134. {
  135. auto& vm = this->vm();
  136. return vm.throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "Location.host setter");
  137. }
  138. // https://html.spec.whatwg.org/multipage/history.html#dom-location-hostname
  139. WebIDL::ExceptionOr<String> Location::hostname() const
  140. {
  141. auto& vm = this->vm();
  142. // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
  143. auto const relevant_document = this->relevant_document();
  144. if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
  145. return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
  146. auto url = this->url();
  147. // 2. If this's url's host is null, return the empty string.
  148. if (url.host().has<Empty>())
  149. return String {};
  150. // 3. Return this's url's host, serialized.
  151. return TRY_OR_THROW_OOM(vm, url.serialized_host());
  152. }
  153. WebIDL::ExceptionOr<void> Location::set_hostname(String const&)
  154. {
  155. auto& vm = this->vm();
  156. return vm.throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "Location.hostname setter");
  157. }
  158. // https://html.spec.whatwg.org/multipage/history.html#dom-location-port
  159. WebIDL::ExceptionOr<String> Location::port() const
  160. {
  161. auto& vm = this->vm();
  162. // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
  163. auto const relevant_document = this->relevant_document();
  164. if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
  165. return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
  166. auto url = this->url();
  167. // 2. If this's url's port is null, return the empty string.
  168. if (!url.port().has_value())
  169. return String {};
  170. // 3. Return this's url's port, serialized.
  171. return TRY_OR_THROW_OOM(vm, String::number(*url.port()));
  172. }
  173. WebIDL::ExceptionOr<void> Location::set_port(String const&)
  174. {
  175. auto& vm = this->vm();
  176. return vm.throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "Location.port setter");
  177. }
  178. // https://html.spec.whatwg.org/multipage/history.html#dom-location-pathname
  179. WebIDL::ExceptionOr<String> Location::pathname() const
  180. {
  181. auto& vm = this->vm();
  182. // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
  183. auto const relevant_document = this->relevant_document();
  184. if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
  185. return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
  186. // 2. Return the result of URL path serializing this Location object's url.
  187. return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url().serialize_path()));
  188. }
  189. WebIDL::ExceptionOr<void> Location::set_pathname(String const&)
  190. {
  191. auto& vm = this->vm();
  192. return vm.throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "Location.pathname setter");
  193. }
  194. // https://html.spec.whatwg.org/multipage/history.html#dom-location-search
  195. WebIDL::ExceptionOr<String> Location::search() const
  196. {
  197. auto& vm = this->vm();
  198. // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
  199. auto const relevant_document = this->relevant_document();
  200. if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
  201. return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
  202. auto url = this->url();
  203. // 2. If this's url's query is either null or the empty string, return the empty string.
  204. if (!url.query().has_value() || url.query()->is_empty())
  205. return String {};
  206. // 3. Return "?", followed by this's url's query.
  207. return TRY_OR_THROW_OOM(vm, String::formatted("?{}", url.query()));
  208. }
  209. WebIDL::ExceptionOr<void> Location::set_search(String const&)
  210. {
  211. auto& vm = this->vm();
  212. return vm.throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "Location.search setter");
  213. }
  214. // https://html.spec.whatwg.org/multipage/history.html#dom-location-hash
  215. WebIDL::ExceptionOr<String> Location::hash() const
  216. {
  217. auto& vm = this->vm();
  218. // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
  219. auto const relevant_document = this->relevant_document();
  220. if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
  221. return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
  222. auto url = this->url();
  223. // 2. If this's url's fragment is either null or the empty string, return the empty string.
  224. if (!url.fragment().has_value() || url.fragment()->is_empty())
  225. return String {};
  226. // 3. Return "#", followed by this's url's fragment.
  227. return TRY_OR_THROW_OOM(vm, String::formatted("#{}", *url.fragment()));
  228. }
  229. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location-hash
  230. WebIDL::ExceptionOr<void> Location::set_hash(String const& value)
  231. {
  232. // The hash setter steps are:
  233. auto const relevant_document = this->relevant_document();
  234. // 1. If this's relevant Document is null, then return.
  235. if (!relevant_document)
  236. return {};
  237. // 2. If this's relevant Document's origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
  238. if (!relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
  239. return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
  240. // 3. Let copyURL be a copy of this's url.
  241. auto copy_url = this->url();
  242. // 4. Let input be the given value with a single leading "#" removed, if any.
  243. auto input = value.bytes_as_string_view().trim("#"sv, TrimMode::Left);
  244. // 5. Set copyURL's fragment to the empty string.
  245. copy_url.set_fragment(String {});
  246. // 6. Basic URL parse input, with copyURL as url and fragment state as state override.
  247. auto result_url = URLParser::basic_parse(input, {}, copy_url, URLParser::State::Fragment);
  248. // 7. If copyURL's fragment is this's url's fragment, then return.
  249. if (copy_url.fragment() == this->url().fragment())
  250. return {};
  251. // 8. Location-object navigate this to copyURL.
  252. auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
  253. window.did_set_location_href({}, copy_url);
  254. return {};
  255. }
  256. // https://html.spec.whatwg.org/multipage/history.html#dom-location-reload
  257. void Location::reload() const
  258. {
  259. auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
  260. window.did_call_location_reload({});
  261. }
  262. // https://html.spec.whatwg.org/multipage/history.html#dom-location-replace
  263. void Location::replace(String const& url) const
  264. {
  265. auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
  266. // FIXME: This needs spec compliance work.
  267. window.did_call_location_replace({}, url.to_deprecated_string());
  268. }
  269. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location-assign
  270. WebIDL::ExceptionOr<void> Location::assign(String const& url) const
  271. {
  272. // 1. If this's relevant Document is null, then return.
  273. auto const relevant_document = this->relevant_document();
  274. if (!relevant_document)
  275. return {};
  276. // 2. If this's relevant Document's origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
  277. if (!relevant_document->origin().is_same_origin_domain(entry_settings_object().origin()))
  278. return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv);
  279. // 3. Parse url relative to the entry settings object. If that failed, throw a "SyntaxError" DOMException.
  280. auto assign_url = entry_settings_object().parse_url(url);
  281. if (!assign_url.is_valid())
  282. return WebIDL::SyntaxError::create(realm(), DeprecatedString::formatted("Invalid URL '{}'", url));
  283. // 4. Location-object navigate this to the resulting URL record.
  284. auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
  285. window.did_set_location_href({}, assign_url);
  286. return {};
  287. }
  288. // 7.10.5.1 [[GetPrototypeOf]] ( ), https://html.spec.whatwg.org/multipage/history.html#location-getprototypeof
  289. JS::ThrowCompletionOr<JS::Object*> Location::internal_get_prototype_of() const
  290. {
  291. // 1. If IsPlatformObjectSameOrigin(this) is true, then return ! OrdinaryGetPrototypeOf(this).
  292. if (HTML::is_platform_object_same_origin(*this))
  293. return MUST(JS::Object::internal_get_prototype_of());
  294. // 2. Return null.
  295. return nullptr;
  296. }
  297. // 7.10.5.2 [[SetPrototypeOf]] ( V ), https://html.spec.whatwg.org/multipage/history.html#location-setprototypeof
  298. JS::ThrowCompletionOr<bool> Location::internal_set_prototype_of(Object* prototype)
  299. {
  300. // 1. Return ! SetImmutablePrototype(this, V).
  301. return MUST(set_immutable_prototype(prototype));
  302. }
  303. // 7.10.5.3 [[IsExtensible]] ( ), https://html.spec.whatwg.org/multipage/history.html#location-isextensible
  304. JS::ThrowCompletionOr<bool> Location::internal_is_extensible() const
  305. {
  306. // 1. Return true.
  307. return true;
  308. }
  309. // 7.10.5.4 [[PreventExtensions]] ( ), https://html.spec.whatwg.org/multipage/history.html#location-preventextensions
  310. JS::ThrowCompletionOr<bool> Location::internal_prevent_extensions()
  311. {
  312. // 1. Return false.
  313. return false;
  314. }
  315. // 7.10.5.5 [[GetOwnProperty]] ( P ), https://html.spec.whatwg.org/multipage/history.html#location-getownproperty
  316. JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> Location::internal_get_own_property(JS::PropertyKey const& property_key) const
  317. {
  318. auto& vm = this->vm();
  319. // 1. If IsPlatformObjectSameOrigin(this) is true, then:
  320. if (HTML::is_platform_object_same_origin(*this)) {
  321. // 1. Let desc be OrdinaryGetOwnProperty(this, P).
  322. auto descriptor = MUST(Object::internal_get_own_property(property_key));
  323. // 2. If the value of the [[DefaultProperties]] internal slot of this contains P, then set desc.[[Configurable]] to true.
  324. auto property_key_value = property_key.is_symbol()
  325. ? JS::Value { property_key.as_symbol() }
  326. : JS::PrimitiveString::create(vm, property_key.to_string());
  327. if (m_default_properties.contains_slow(property_key_value))
  328. descriptor->configurable = true;
  329. // 3. Return desc.
  330. return descriptor;
  331. }
  332. // 2. Let property be CrossOriginGetOwnPropertyHelper(this, P).
  333. auto property = HTML::cross_origin_get_own_property_helper(const_cast<Location*>(this), property_key);
  334. // 3. If property is not undefined, then return property.
  335. if (property.has_value())
  336. return property;
  337. // 4. Return ? CrossOriginPropertyFallback(P).
  338. return TRY(HTML::cross_origin_property_fallback(vm, property_key));
  339. }
  340. // 7.10.5.6 [[DefineOwnProperty]] ( P, Desc ), https://html.spec.whatwg.org/multipage/history.html#location-defineownproperty
  341. JS::ThrowCompletionOr<bool> Location::internal_define_own_property(JS::PropertyKey const& property_key, JS::PropertyDescriptor const& descriptor)
  342. {
  343. // 1. If IsPlatformObjectSameOrigin(this) is true, then:
  344. if (HTML::is_platform_object_same_origin(*this)) {
  345. // 1. If the value of the [[DefaultProperties]] internal slot of this contains P, then return false.
  346. // 2. Return ? OrdinaryDefineOwnProperty(this, P, Desc).
  347. return JS::Object::internal_define_own_property(property_key, descriptor);
  348. }
  349. // 2. Throw a "SecurityError" DOMException.
  350. return throw_completion(WebIDL::SecurityError::create(realm(), DeprecatedString::formatted("Can't define property '{}' on cross-origin object", property_key)));
  351. }
  352. // 7.10.5.7 [[Get]] ( P, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-get
  353. JS::ThrowCompletionOr<JS::Value> Location::internal_get(JS::PropertyKey const& property_key, JS::Value receiver, JS::CacheablePropertyMetadata* cacheable_metadata) const
  354. {
  355. auto& vm = this->vm();
  356. // 1. If IsPlatformObjectSameOrigin(this) is true, then return ? OrdinaryGet(this, P, Receiver).
  357. if (HTML::is_platform_object_same_origin(*this))
  358. return JS::Object::internal_get(property_key, receiver, cacheable_metadata);
  359. // 2. Return ? CrossOriginGet(this, P, Receiver).
  360. return HTML::cross_origin_get(vm, static_cast<JS::Object const&>(*this), property_key, receiver);
  361. }
  362. // 7.10.5.8 [[Set]] ( P, V, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-set
  363. JS::ThrowCompletionOr<bool> Location::internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver)
  364. {
  365. auto& vm = this->vm();
  366. // 1. If IsPlatformObjectSameOrigin(this) is true, then return ? OrdinarySet(this, P, V, Receiver).
  367. if (HTML::is_platform_object_same_origin(*this))
  368. return JS::Object::internal_set(property_key, value, receiver);
  369. // 2. Return ? CrossOriginSet(this, P, V, Receiver).
  370. return HTML::cross_origin_set(vm, static_cast<JS::Object&>(*this), property_key, value, receiver);
  371. }
  372. // 7.10.5.9 [[Delete]] ( P ), https://html.spec.whatwg.org/multipage/history.html#location-delete
  373. JS::ThrowCompletionOr<bool> Location::internal_delete(JS::PropertyKey const& property_key)
  374. {
  375. // 1. If IsPlatformObjectSameOrigin(this) is true, then return ? OrdinaryDelete(this, P).
  376. if (HTML::is_platform_object_same_origin(*this))
  377. return JS::Object::internal_delete(property_key);
  378. // 2. Throw a "SecurityError" DOMException.
  379. return throw_completion(WebIDL::SecurityError::create(realm(), DeprecatedString::formatted("Can't delete property '{}' on cross-origin object", property_key)));
  380. }
  381. // 7.10.5.10 [[OwnPropertyKeys]] ( ), https://html.spec.whatwg.org/multipage/history.html#location-ownpropertykeys
  382. JS::ThrowCompletionOr<JS::MarkedVector<JS::Value>> Location::internal_own_property_keys() const
  383. {
  384. // 1. If IsPlatformObjectSameOrigin(this) is true, then return OrdinaryOwnPropertyKeys(this).
  385. if (HTML::is_platform_object_same_origin(*this))
  386. return JS::Object::internal_own_property_keys();
  387. // 2. Return CrossOriginOwnPropertyKeys(this).
  388. return HTML::cross_origin_own_property_keys(this);
  389. }
  390. }