2009-06-23

firefoxのcanvasにおける不思議なorigin判定

ローカル上のドキュメントから見て、ローカル上のおなじディレクトリ内のファイルに対して、originが違うと判断する。

再現方法:ローカルディスクの同じディレクトリに、HTMLファイルと画像ファイルを置く。HTMLファイルで、canvas上に画像ファイルを描画する。而る後に、そのcanvasに対して、toDataURL()を呼び出す。あるいは、canvasのcontextに対して、getImageData()を呼び出す。

Firefoxの場合、SECURITY_ERR例外が投げられる。

ローカル上の、それも同じディレクトリ内にあるファイルなのだから、originは同じはずだ。なぜかFirefoxだけ例外が投げられる。なお、ローカルではない場合は、Firefoxは正しく動作する。

問題は、ローカル上のファイルをどう扱うかというのは、定義されていないということだ。

If scheme is "file", then the user agent may return a UA-specific value.

http://dev.w3.org/html5/spec/Overview.html#origin-0

しかし、ローカル上のドキュメントの場合、同じディレクトリの中にあるファイルは、same originと判断しても差し支えないのではあるまいか。

ちなみに、Chrome、Safari、Operaでは、ローカル上のドキュメントから見て、ローカル上のファイルは、同じディレクトリにあろうがなかろうが、すべて、同じoriginだと判断される。

テストコード

No comments:

Post a Comment

You can use some HTML elements, such as <b>, <i>, <a>, also, some characters need to be entity referenced such as <, > and & Your comment may need to be confirmed by blog author. Your comment will be published under GFDL 1.3 or later license with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.