1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/browser.h"
6 #include "chrome/browser/ui/tabs/tab_strip_model.h"
7 #include "chrome/common/url_constants.h"
8 #include "chrome/test/base/in_process_browser_test.h"
9 #include "chrome/test/base/ui_test_utils.h"
10 #include "content/public/browser/navigation_details.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/test/browser_test_utils.h"
14 using content::WebContents
;
18 const char kSharedWorkerTestPage
[] =
19 "files/workers/workers_ui_shared_worker.html";
20 const char kSharedWorkerJs
[] =
21 "files/workers/workers_ui_shared_worker.js";
23 class InspectUITest
: public InProcessBrowserTest
{
28 DISALLOW_COPY_AND_ASSIGN(InspectUITest
);
31 // The test fails on Mac OS X and Windows, see crbug.com/89583
32 // Intermittently fails on Linux.
33 IN_PROC_BROWSER_TEST_F(InspectUITest
, DISABLED_SharedWorkersList
) {
34 ASSERT_TRUE(test_server()->Start());
35 GURL url
= test_server()->GetURL(kSharedWorkerTestPage
);
36 ui_test_utils::NavigateToURL(browser(), url
);
38 ui_test_utils::NavigateToURLWithDisposition(
40 GURL(chrome::kChromeUIInspectURL
),
42 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION
);
44 WebContents
* web_contents
=
45 browser()->tab_strip_model()->GetActiveWebContents();
46 ASSERT_TRUE(web_contents
!= NULL
);
50 content::ExecuteScriptAndExtractString(
52 "window.domAutomationController.send("
53 " '' + document.body.textContent);",
55 ASSERT_TRUE(result
.find(kSharedWorkerJs
) != std::string::npos
);
56 ASSERT_TRUE(result
.find(kSharedWorkerTestPage
) != std::string::npos
);
59 IN_PROC_BROWSER_TEST_F(InspectUITest
, ReloadCrash
) {
60 ASSERT_TRUE(test_server()->Start());
61 // Make sure that loading the inspect UI twice in the same tab
62 // connects/disconnects listeners without crashing.
63 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIInspectURL
));
64 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIInspectURL
));