当我测试SOP时,我遇到这种情况,两个文档与我期望的域具有相同的关系,当我尝试获取位置时会引发错误。
重现该问题:
let opened = window.open("https://www.google.com")opened.location.toString(),它将返回正确的位置document.domain = "www.google.com"从第一个选项卡做opened.location.toString(),您将得到一个错误
Uncaught DOMException: Blocked a frame with origin "https://www.google.com" from accessing a cross-origin frame.
at <anonymous>:1:12
Run Code Online (Sandbox Code Playgroud)谁能解释这个奇怪的行为?