summaryrefslogtreecommitdiff
path: root/chromium/content/browser/presentation/presentation_browsertest.cc
blob: 12aa1c5ba226ea462f043bd45339a2184f0cdbdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/shell/browser/shell.h"

namespace content {

using PresentationBrowserTest = ContentBrowserTest;

// Regression test that verifies that calling getAvailability() twice on the
// same PresentationRequest does not return an undefined object.
// TODO(mlamouri,mfoltz), update the test after [SameObject] is used,
// see https://crbug.com/653131
IN_PROC_BROWSER_TEST_F(PresentationBrowserTest, AvailabilityNotUndefined) {
  GURL test_url = GetTestUrl("", "hello.html");

  TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
  shell()->LoadURL(test_url);

  navigation_observer.Wait();

  ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
                           "const r = new PresentationRequest('foo.html')");

  ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
                           "const p1 = r.getAvailability();");

  ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
                           "const p2 = r.getAvailability()");

  bool is_p1_undefined = false;
  ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
                           "p1 === undefined")->GetAsBoolean(&is_p1_undefined);

  bool is_p2_undefined = false;
  ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
                           "p2 === undefined")->GetAsBoolean(&is_p2_undefined);

  EXPECT_FALSE(is_p1_undefined);
  EXPECT_FALSE(is_p2_undefined);
}

}  // namespace content