[webkit-dev] setTimeout and Safari
Xianzhu Wang
phnixwxz at gmail.com
Thu Oct 7 23:04:12 PDT 2010
I think a different way works: hooking window.setTimeout,
window.setInterval, window.clearTimeout and window.clearInterval after
the page is loaded and before any script is run, like the following:
(function() {
var orgSetTimeout = window.setTimeout;
window.setTimeout = function(f, t) {
...
var id = orgSetTimeout(function() {
...
f();
}, t);
...
return id;
};
...
})();
In Chrome, this can be done with a run_at document_start content
script in an extension.
Xianzhu
2010/10/8 Steve Conover <sconover at gmail.com>:
> It's true. Maybe I'm wrong about this but it seems to me that at some
> point most pages "settle". I'm also planning to put in a hard timeout
> in what I'm building. And I'm slightly more concerned about js than
> css.
>
> Do you know of a good way at getting at an event queue or something
> else containing a list or a count of upcoming setTimeout/setInterval
> operations, in either Safari or QtWebKit?
>
>
> On Thu, Oct 7, 2010 at 12:41 PM, Simon Fraser <simon.fraser at apple.com> wrote:
>> On Oct 7, 2010, at 12:23 PM, Steve Conover wrote:
>>
>>> So that I don't have to guess whether a page is "done" rendering.
>>> Many developers defer rendering using setTimeout, I'd like to wait
>>> until setTimeouts are done and then just after check the result. This
>>> would be superior to guessing at a sleep interval in the calling code.
>>
>> Are you trying to choose a good time to snapshot the page?
>>
>> There are many things that can cause the page to keep changing; chained
>> setTimeouts, setInterval, CSS transitions and animations, SVG animation,
>> plugins etc etc. This is not a simple question to answer.
>>
>> Simon
>>
>>>
>>> On Wed, Oct 6, 2010 at 5:54 PM, Simon Fraser <simon.fraser at apple.com> wrote:
>>>> Why do you need to know if there are no more pending setTimeouts?
>>>>
>>>> Simon
>>>>
>>>> On Oct 6, 2010, at 5:52 PM, Steve Conover wrote:
>>>>
>>>>> Hoping someone on -dev might have an idea about this...
>>>>>
>>>>> -Steve
>>>>>
>>>>>
>>>>> ---------- Forwarded message ----------
>>>>> From: Steve Conover <sconover at gmail.com>
>>>>> Date: Tue, Sep 28, 2010 at 11:19 PM
>>>>> Subject: Re: setTimeout and Safari
>>>>> To: webkit-help at lists.webkit.org
>>>>>
>>>>>
>>>>> Actually I am discovering what one might describe as a "normal"
>>>>> problem here...how to know when the setTimeout's are done firing. The
>>>>> ideal would that I could somehow drill into the dom implementation and
>>>>> ask whether any setTimeout events are waiting to fire (and stop
>>>>> polling if the queue length is zero).
>>>>>
>>>>> I'm sure that's way off in terms of how this is actually implemented.
>>>>> Does such a thing exist? Could someone please point me to the
>>>>> relevant sourcecode?
>>>>>
>>>>> Regards,
>>>>> Steve
>>>>>
>>>>> On Tue, Sep 28, 2010 at 10:36 PM, Steve Conover <sconover at gmail.com> wrote:
>>>>>> Sigh. Please disregard. After an hour of troubleshooting, I sent
>>>>>> this email, and two minutes later realized the problem was bad js
>>>>>> (blush).
>>>>>>
>>>>>> On Tue, Sep 28, 2010 at 10:22 PM, Steve Conover <sconover at gmail.com> wrote:
>>>>>>> I hope this is the right place to be asking this question.
>>>>>>>
>>>>>>> I'm using the cocoa api, and am able to load a web page in a WebView.
>>>>>>> However I have some javascript in the page that uses setTimeout to
>>>>>>> cause a function to fire 100ms into the future - but the page loads
>>>>>>> and ignores the setTimeout's.
>>>>>>>
>>>>>>> How do I get my setTimeout's to fire? I suspect this has something to
>>>>>>> do with the Run Loop, but my experiments so far with various parts of
>>>>>>> the Run Loop api have been failures.
>>>>>>>
>>>>>>> Regards,
>>>>>>> Steve
>>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> webkit-dev mailing list
>>>>> webkit-dev at lists.webkit.org
>>>>> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>>>>
>>>>
>>
>>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
More information about the webkit-dev
mailing list