Skip to content

Instantly share code, notes, and snippets.

@froop
Created May 10, 2011 22:38
Show Gist options
  • Save froop/965530 to your computer and use it in GitHub Desktop.
Save froop/965530 to your computer and use it in GitHub Desktop.
[JavaScript] Firefox4+Greasemonkey のバグ。ページ表示タイミングでalertするとsetTimeoutやAjaxが無応答
// ==UserScript==
// @include http://www.google.co.jp/*
// ==/UserScript==
alert(1); setTimeout(function() { alert(2) }, 0);
@froop
Copy link
Author

froop commented May 10, 2011

Firefox4上の Greasemonkey 0.9.2 で実行すると、2つ目のalertが発生しない。また Google Suggest もされなくなる。
当該タブを閉じない限り、Greasemonkeyスクリプト外でも他のページに遷移しても解消しない。
Firefox3系では発生しない。

Copy link

ghost commented May 11, 2011

greasemonkey/greasemonkey#1318
issuesに似たようなのが上がってますね

@froop
Copy link
Author

froop commented May 11, 2011

ほんとですね。ありがとうございます。
結局、Firefox本体のバグみたいです。英語なんでよく読んでないですけどw
https://bugzilla.mozilla.org/show_bug.cgi?id=647727

@froop
Copy link
Author

froop commented May 12, 2011

回避策は、直接のalertをsetTimeoutで間接的な形に変える。
setTimeout(function() { alert(1) }, 0);
setTimeout(function() { alert(2) }, 0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment