Make sure CSS agent messages flush before testing.

While working on updating active stylesheets as part of the style and
layout tree update in [1], two inspector tests started failing. The
reason was these tests rely on a console message to trigger a step in
the test after the active stylesheets have been pushed to the inspector
client. But even if the stylesheets were updated in InspectorCSSAgent
before the console message was sent, the console message arrived in the
client before the new active stylesheets. The reason was that the
console message is immediately flushed, while the messages from the
InspectorCSSAgent are lazily flushed from WebDevToolsAgentImpl::
didProcessTask.

I tried to force the active stylesheet update with a forced layout tree
update like this:

  document.documentElement.offsetTop;
  console.log(...);

But, due the console.log message being dispatched first as described
above, I ended up postponing the console.log with a rAF which means it
will run in a later task and the didProcessTask will trigger in between
to flush the active stylesheet message(s).

Note that this was not currently causing any failures. It's done in
preparation for landing changes for 567021 without breaking anything.

Looking at TestExpectations, I noticed crbug.com/597572, which might be
a similar issue.

[1] https://codereview.chromium.org/1913833002/

R=pfeldman@chromium.org,dgozman@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2049283002
Cr-Commit-Position: refs/heads/master@{#398825}
1 file changed