window.content.document.getSelection()にアクセスした時の変なメッセージが出る

Safely accessing content DOM from chrome - MDCあたりが関係しているのだと思うけど、chrome内の保護されたスクリプトから信頼できないオブジェクトへアクセスする場合の話。

Firefox ErrorConsole
Firefoxエラーコンソールのメッセージ

Deprecated method document.getSelection() called. Please use window.getSelection() instead.

chrome内からwindow.content.document.getSelection()を実行すると上記のようなメッセージがエラーコンソールに出力される。でも、window.content.getSelection()の方が危険なんだよ。

getSelection_test.html

<html>
<head>
<title>getSelection Test</title>
<script type="text/javascript">
window.getSelection = function(){
    return "window.getSelectionだよん";
}
</script>
</head>
<body>
<h1>getSelection Test</h1>
</body>
</html>

のようなコード上でwindow.content.document.getSelection()を使用するとwindow.getSelectionだよんが返ってきてしまう。ブラウザ内のスクリプト(信頼できないオブジェクト)が実行されてしまうのだ。

window.content.getSelectionオブジェクトを見ると

function () {
    return "window.getSelectionだよん"
}

となるが、window.content.document.getSelectionだと

function XPCNativeWrapper function wrapper() {
    [native code]
}

となり、XPCNativeWrapperで保護されている事が分かる。実際こちらをつかえば本来の選択された要素を得る事ができる。

なのに、エラーコンソールには上のようなメッセージが出力されてしまう。逆にwindow.content.getSelectionを使うと何事も無かったかのように沈黙している。これは非常に紛らわしい。保護されたスクリプトから信頼できないオブジェクトへアクセスしたら警告を出して良いレベルだと思うのに...。