mb增加關閉iframe跨域檢查功能

2021-08-20 00:27:55 字數 1298 閱讀 9959

在主frame,使用

var frame = document.getelementbyid("login_frame");

console.log('haha2:' + dom.contentwindow);

這種方式訪問子frame,存在跨域問題。

那麼怎麼在chromium裡去掉這個檢查呢。經過除錯,發現僅僅去掉securityorigin::canaccess之類還是不行,

原因是如下堆疊:

blink::v8window::namedpropertygettercustom

blink::domwindowv8internal::namedpropertygettercallback

v8::internal::propertycallbackarguments::call

v8::internal::`anonymous namespace'::getpropertywithinterceptorinternal

v8::internal::jsobject::getpropertywithinterceptor

v8::internal::object::getproperty

v8::internal::jsreceiver::getproperty

v8::internal::object::getmethod

v8::internal::jsreceiver::toprimitive

v8::internal::object::toprimitive

v8::internal::object::add

v8::internal::binaryopic::transition

v8::internal::runtime_binaryopic_miss

會去取symbol.toprimitive,

關鍵就是這個object::getproperty,會呼叫it->hasaccess()去請求是否有訪問許可權。

it->hasaccess()裡的邏輯是先檢查

context::cast(receiver_context)->security_token() ==  native_context->security_token()

再檢查v8windows裡設定的

domwindowv8internal::securitycheck。

所以只要在windowproxy::setsecuritytoken裡

把所有securitytoken都用context->setsecuritytoken

設定成一樣的,v8就全都放行了。

iframe跨域通訊

簡述 window.postmessage方法,允許跨視窗通訊,不論這兩個視窗是否同源。視窗都可以通過message事件,監聽對方的訊息。語法 otherwindow.postmessage message,targetorigin,transfer message 傳送的內容。targetorgi...

iframe解決跨域

iframe的使用a域中有parent.html,b域中有child.html.b域中的伺服器要監聽所有b域下所有child.html,並且兩個域之間要交換資料.那麼在a域中嵌入iframe 如 parent.html document.domain ip a域的ip或網域名稱 去掉www 函式fu...

iframe跨域訪問

子iframe使用jquery訪問父頁面時,報錯uncaught domexception blocked a frame with origin url from accessing a cross origin frame.這是跨域導致的 設host 進行網域名稱重定向,開啟c windows ...