Skip to content

Commit

Permalink
Add a test for DevTools extensions on OTR NTP
Browse files Browse the repository at this point in the history
Upstream fix: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2216940

Bug: 1085228
Change-Id: I641542cd65f18a573a291a7e3f0feebce7b69ea3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216708
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Peter Kvitek <kvitekp@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772482}
  • Loading branch information
caseq authored and Commit Bot committed May 28, 2020
1 parent 09ac2af commit 3b4458a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions chrome/browser/devtools/devtools_sanity_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/lifetime/browser_shutdown.h"
Expand Down Expand Up @@ -256,6 +257,14 @@ class DevToolsSanityTest : public InProcessBrowserTest {
is_docked);
}

void OpenDevToolsWindowOnOffTheRecordTab(const std::string& test_page) {
GURL url = spawned_test_server()->GetURL("").Resolve(test_page);
auto* otr_browser = OpenURLOffTheRecord(browser()->profile(), url);

window_ = DevToolsWindowTesting::OpenDevToolsWindowSync(
otr_browser->tab_strip_model()->GetWebContentsAt(0), false);
}

WebContents* GetInspectedTab() {
return browser()->tab_strip_model()->GetWebContentsAt(0);
}
Expand Down Expand Up @@ -852,6 +861,25 @@ IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest,
RunTest("waitForTestResultsInConsole", std::string());
}

// Tests that chrome.devtools extension is correctly exposed.
IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, TestExtensionOnNewTab) {
// Not really required by this test, but the underlying code happens
// to expect it.
ASSERT_TRUE(embedded_test_server()->Start());
// Install the dynamically-generated devtools extension.
const Extension* devtools_extension = LoadExtensionForTest(
"Devtools Extension", "panel_devtools_page.html", "");
ASSERT_TRUE(devtools_extension);
extensions::util::SetIsIncognitoEnabled(devtools_extension->id(),
browser()->profile(), true);

OpenDevToolsWindowOnOffTheRecordTab(chrome::kChromeUINewTabURL);

// Wait for the extension's panel to finish loading -- it'll output 'PASS'
// when it's installed. waitForTestResultsInConsole waits until that 'PASS'.
RunTestFunction(window_, "waitForTestResultsInConsole");
}

// Tests that http Iframes within the visible devtools panel for the devtools
// extension are rendered in their own processes and not in the devtools process
// or the extension's process. This is tested because this is one of the
Expand Down

0 comments on commit 3b4458a

Please sign in to comment.