Skip to content

Commit

Permalink
SetContentAsync improvements (#844)
Browse files Browse the repository at this point in the history
Load LifecycleWatcher before injecting the HTML
  • Loading branch information
kblok authored Jan 8, 2019
1 parent 9cb7ecf commit 02efcdd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/PuppeteerSharp/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -557,17 +557,16 @@ public async Task SetContentAsync(string html, NavigationOptions options = null)
{
var waitUntil = options?.WaitUntil ?? new[] { WaitUntilNavigation.Load };
var timeout = options?.Timeout ?? Puppeteer.DefaultTimeout;

// We rely upon the fact that document.open() will reset frame lifecycle with "init"
// lifecycle event. @see https://crrev.com/608658
var watcher = new LifecycleWatcher(FrameManager, this, waitUntil, timeout);

// We rely upon the fact that document.open() will reset frame lifecycle with "init"
// lifecycle event. @see https://crrev.com/608658
await EvaluateFunctionAsync(@"html => {
document.open();
document.write(html);
document.close();
}", html);

var watcher = new LifecycleWatcher(FrameManager, this, waitUntil, timeout);

var watcherTask = await Task.WhenAny(
watcher.TimeoutOrTerminationTask,
watcher.LifecycleTask).ConfigureAwait(false);
Expand Down

0 comments on commit 02efcdd

Please sign in to comment.