Skip to content
This repository

setTimeout broken again in 1.0 #1620

Closed
peci1 opened this Issue August 31, 2012 · 7 comments

3 participants

Martin Pecka arantius Brock
Martin Pecka

Hello, bad news... setTimeout() ceased working for me after update to 1.0

I tried setting:
@grant none
@grant GM_util
@grant GM_util.timeout
@grant setTimeout
none of which work.

Thanks for any help ;)

arantius
Collaborator

You're going to need to be much more specific; works fine for me.

Provide a link to an exact script, the shorter the better, that doesn't work for you. (Plus, setTimeout is not a Greasemonkey API, so @grant is unrelated.)

Martin Pecka

Okay, here is a sample code:

// ==UserScript==
// @name        test
// @namespace   server.gvn.cz/~mp890318
// @include     https://github.com/greasemonkey/greasemonkey/issues/1620
// @grant GM_util
// @grant GM_util.timeout
// @version     1
// ==/UserScript==
alert("test1");
setTimeout('alert("test2")', 500);

The string "test1" is shown, whereas "test2" is never shown.

Brock

@peci1, your test script would probably work if you used @grant none, and no other grants.

However, that is a poor way to use setTimeout. Avoid "eval" strings whenever you can.

A more proper usage, will also work irregardless of the @grant settings.

//-- Traditional
setTimeout ( function () {
    alert ("test2");
    }, 500
);

//-- Okay for most modern browsers (certainly for Greasemonkey)
setTimeout (alert, 500, "test2");
arantius
Collaborator

The issue originally from #1318 is indeed happening in the @grant none case. The underlying Firefox bug is fixed and slated to be released in Firefox 16.

Otherwise, in 15, I am indeed seeing strange behavior that I've yet to 100% explain.

Brock

@arantius,

// ==UserScript==
// @name        _del5
// @namespace   _pc
// @include     https://github.com/greasemonkey/greasemonkey/issues/*
// @grant       none
// ==/UserScript==

setTimeout('alert("test2")', 500);

works fine for me.

(FF 15.0, GM 1.0, Win XP)

Martin Pecka

Seems to be a little bit weird.

The script from @BrockA works fine.

My script works well on most pages (after changing the include clause), but when I run it a lot of times, then the second alert stops working. Even duplicating the tab with bad behavior helps, the duplicated page shows two alerts.

Most of my setTimeout statements have started to work as expected yesterday (but I don't know of a recent update to FF or GM).

arantius
Collaborator

Test script: https://gist.github.com/3656920

Behaves as expected (setTimeout broken after alert); the bug from issue #1318 is back in the grant-none mode. If I edit none to GM_log, then it works again as expected (I see three alerts).

If I edit the setTimeout lines, then in the legacy case I see one global-model alert, then two tab-modal alerts (not exactly broken, but admittedly weird; this will go away in Firefox 16). If I then go back to grant none, I see one tab-modal alert, and then still brokenness as expected.

arantius arantius closed this issue from a commit September 06, 2012
Commit has since been removed from the repository and is no longer available.
arantius arantius closed this in 9acad2d September 06, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.