Add global setTimeout/setInterval for frame scripts




DOM: Content Processes
7 years ago
4 years ago


(Reporter: cjones, Unassigned)



Firefox Tracking Flags



For tests that don't need to initially wait, the reftest harness sets up a timeout from its onload handler like so

        content.setTimeout(content.setTimeout, 0, AfterOnLoadScripts, 0);

In these tests


the setTimeout function enqueued by reftest-content.js is never called.  I tried changing that somewhat complicated incantation above to something simpler like |content.setTimeout(function () { dump('foo\n') }, 1000)|, but nothing worked.

These tests both do document.write from their own onload handlers.  Maybe some scope/principal/compartment is getting mixed up and the setTimeout from the harness is being ignored?  I dunno.  Disabling those tests for now.

This affects both remote=true/false frame scripts.

There was a similar-looking problem in


in which a setTimeout() made by the test in an inline <script> element never ran and the test looped forever.  Changing this setTimeout() to be enqueued off an onload handler fixed the problem.  These bugs might perhaps be related.
This should block fennec because whatever the bug is can strike the fennec frontend and extensions in the same way reftest-content.js is being affected.
tracking-fennec: --- → ?
Oops, missed two others: similar symptoms also appear in

If document.write is called after the original page is parsed, new inner window 
If setTimeout was called using the old window, it is expected that it doesn't
get called.

So I believe this is INVALID.
Well OK, but if so, how are frame scripts supposed to reliably enqueue tasks?  Do we need setTimeout/setInterval globals for frame scripts?
That doesn't sound very friendly to extension authors.  Are there other cases in ff 3.6 where extensions would be forced to use nsITimer directly, on the main thread?  I can't think of any.
OK, let me try another tack.

Are there reasons *not* to add global setTimeout/setInterval for frame scripts?
Other than extracting timeout/interval code, or at least the behavior from
nsGlobalWindow is non-trivial, there shouldn't be any reason
not to add setTimeout/setInterval to frame scripts.
I had to do it for workers an it was a little tricky. We have some unexpected behavior, accepting strings and functions, passing extra arguments, etc.
Mid-aired with bent, but I'll repost unedited ;) ---

The dom/src/threads code doesn't look too bad.  But we can discuss the impl more when/if this is blocking-fennec+.
Summary: content.setTimeout doesn't work from frame scripts in some cases (something to do with onload and document.write?) → Add global setTimeout/setInterval for frame scripts
348887-1.html was something different.  Filed bug 623091.
love to see this happen, but we will not block fennec 4
tracking-fennec: ? → 2.0-
Whiteboard: [fennec-4.1?]
Whiteboard: [fennec-4.1?]
Depends on: 840360


4 years ago
Component: IPC → DOM: Content Processes
You need to log in before you can comment on or make changes to this bug.