summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/inspect_ui_browsertest.cc
blob: 158cd0b2ccd6ce73ea4262137b1d75aec0769943 (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
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2012 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 "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"

using content::WebContents;

namespace {

const char kSharedWorkerTestPage[] =
    "files/workers/workers_ui_shared_worker.html";
const char kSharedWorkerJs[] =
    "files/workers/workers_ui_shared_worker.js";

class InspectUITest : public InProcessBrowserTest {
 public:
  InspectUITest() {}

 private:
  DISALLOW_COPY_AND_ASSIGN(InspectUITest);
};

// The test fails on Mac OS X and Windows, see crbug.com/89583
// Intermittently fails on Linux.
IN_PROC_BROWSER_TEST_F(InspectUITest, DISABLED_SharedWorkersList) {
  ASSERT_TRUE(test_server()->Start());
  GURL url = test_server()->GetURL(kSharedWorkerTestPage);
  ui_test_utils::NavigateToURL(browser(), url);

  ui_test_utils::NavigateToURLWithDisposition(
      browser(),
      GURL(chrome::kChromeUIInspectURL),
      NEW_FOREGROUND_TAB,
      ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);

  WebContents* web_contents =
      browser()->tab_strip_model()->GetActiveWebContents();
  ASSERT_TRUE(web_contents != NULL);

  std::string result;
  ASSERT_TRUE(
      content::ExecuteScriptAndExtractString(
          web_contents,
          "window.domAutomationController.send("
          "    '' + document.body.textContent);",
          &result));
  ASSERT_TRUE(result.find(kSharedWorkerJs) != std::string::npos);
  ASSERT_TRUE(result.find(kSharedWorkerTestPage) != std::string::npos);
}

}  // namespace