Maintain timer ordering when alignment is used
Prior to this patch, timers were not getting executed in the correct
order when timer alignment was turned on (e.g., for background tabs).
This was because of two reasons:
1. Timers were scheduled by computing the delay from the current time to
the desired run time and passing that delay to the platform layer.
When alignment is enabled, all timers are trying to aim for the exact
same point in time. This meant that the timers were getting scheduled
with delays that were very close to each other, leading to a random
order of execution.
2. When the alignment timer alignment was changed, each timer was getting
rescheduled in random order. This meant that timers that were
targeting the same aligned time would again be executed in a random
order.
This patch fixes the first problem by passing the desired run time
instead of the delay to the platform layer. This enables the platform
to consistently schedule timers for the same point in time based on
their posted order.
The second problem is fixed by rescheduling timers in the order of their
desired run time when the timer alignment changes.
Note that the Chromium side patch which implements postTimerTaskAt
needs to land before this one.
BUG=508279
TEST=fast/dom/timers-maintain-order-while-throttled.html
Review URL: https://codereview.chromium.org/
1227403005
git-svn-id: svn://svn.chromium.org/blink/trunk@199114 bbb929c8-8fbe-4397-9dbb-9b2b20218538