Commit 2203ab11 authored by Roman Karasev's avatar Roman Karasev Committed by Commit Bot

Correct URL for extension with incognito:spanning mode

SetUpExtensionFunction loads "main.html" for each extension by default,
but if an extension has "incognito: spanning" in its manifest, then
"main.html" of that extension cannot be loaded because of restriction.
You did not see failed tests because RenderFrameHost is destroyed after
extension function is executed in test. There is a logical race in IO/UI
threads and it is reproduced on some PCs with Windows (on these PCs
RenderFrameHost is destroyed earlier then extension function is
executed).

R=dtrainor@chromium.org,qinmin@chromium.org

TEST: if you will wait for navigation of chrome::AddSelectedTabWithURL
(e.g. by adding TestNavigationObserver) you can see the broblem.

Bug: None
Change-Id: Ibf8fe519fd6d041fd52ec9aa697d220a55103b53
Reviewed-on: https://chromium-review.googlesource.com/1158070Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589241}
parent 6e4445d1
......@@ -56,6 +56,7 @@
#include "content/public/test/test_utils.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/notification_types.h"
#include "extensions/common/manifest_handlers/incognito_info.h"
#include "net/base/data_url.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
......@@ -659,11 +660,13 @@ class DownloadExtensionTest : public ExtensionApiTest {
private:
void SetUpExtensionFunction(UIThreadExtensionFunction* function) {
if (extension_) {
const GURL url = current_browser_ == incognito_browser_ &&
!IncognitoInfo::IsSplitMode(extension_)
? GURL(url::kAboutBlankURL)
: extension_->GetResourceURL("empty.html");
// Recreate the tab each time for insulation.
content::WebContents* tab = chrome::AddSelectedTabWithURL(
current_browser(),
extension_->GetResourceURL("empty.html"),
ui::PAGE_TRANSITION_LINK);
current_browser(), url, ui::PAGE_TRANSITION_LINK);
function->set_extension(extension_);
function->SetRenderFrameHost(tab->GetMainFrame());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment