summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 07:43:20 +0000
committerkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 07:43:20 +0000
commit909851a5b99ce386a0559804e7bc4b5b761337a7 (patch)
tree5458ea39293cf1dcbede69329be083584629f1e0
parent78c43424b469237fce375bc048bb4c51712a68c4 (diff)
downloadchromium_src-909851a5b99ce386a0559804e7bc4b5b761337a7.zip
chromium_src-909851a5b99ce386a0559804e7bc4b5b761337a7.tar.gz
chromium_src-909851a5b99ce386a0559804e7bc4b5b761337a7.tar.bz2
Added automated test of selecting "Reload" button on WebGL infobar. There's no good way to test selecting the "Ignore" button.
BUG=164787 TEST=GPUCrashTest.ContextLossInfobarReload Review URL: https://chromiumcodereview.appspot.com/11568052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173681 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/test/gpu/gpu_crash_browsertest.cc51
-rw-r--r--content/test/data/gpu/webgl.html12
2 files changed, 62 insertions, 1 deletions
diff --git a/chrome/test/gpu/gpu_crash_browsertest.cc b/chrome/test/gpu/gpu_crash_browsertest.cc
index 2b5d87f..1fec081 100644
--- a/chrome/test/gpu/gpu_crash_browsertest.cc
+++ b/chrome/test/gpu/gpu_crash_browsertest.cc
@@ -5,6 +5,7 @@
#include "base/command_line.h"
#include "base/path_service.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
@@ -114,6 +115,56 @@ IN_PROC_BROWSER_TEST_F(GPUCrashTest, ContextLossRaisesInfobar) {
chrome::GetActiveWebContents(browser()))->GetInfoBarCount());
}
+IN_PROC_BROWSER_TEST_F(GPUCrashTest, ContextLossInfobarReload) {
+ // crbug.com/162982, flaky on Mac Retina Release.
+ if (GPUTestBotConfig::CurrentConfigMatches("MAC NVIDIA 0x0fd5 RELEASE"))
+ return;
+
+ content::DOMMessageQueue message_queue;
+
+ // Load page and wait for it to load.
+ content::WindowedNotificationObserver observer(
+ content::NOTIFICATION_LOAD_STOP,
+ content::NotificationService::AllSources());
+ ui_test_utils::NavigateToURL(
+ browser(),
+ content::GetFileUrlWithQuery(
+ gpu_test_dir_.AppendASCII("webgl.html"),
+ "query=kill_after_notification"));
+ observer.Wait();
+
+ std::string m;
+ ASSERT_TRUE(message_queue.WaitForMessage(&m));
+ EXPECT_EQ("\"LOADED\"", m);
+
+ message_queue.ClearQueue();
+
+ content::WindowedNotificationObserver infobar_added(
+ chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
+ content::NotificationService::AllSources());
+ SimulateGPUCrash(browser());
+ infobar_added.Wait();
+ ASSERT_EQ(1u,
+ InfoBarTabHelper::FromWebContents(
+ chrome::GetActiveWebContents(browser()))->GetInfoBarCount());
+ InfoBarDelegate* delegate =
+ InfoBarTabHelper::FromWebContents(
+ chrome::GetActiveWebContents(browser()))->GetInfoBarDelegateAt(0);
+ ASSERT_TRUE(delegate);
+ ASSERT_TRUE(delegate->AsThreeDAPIInfoBarDelegate());
+ delegate->AsConfirmInfoBarDelegate()->Cancel();
+
+ // The page should reload and another message sent to the
+ // DomAutomationController.
+ m = "";
+ ASSERT_TRUE(message_queue.WaitForMessage(&m));
+ EXPECT_EQ("\"LOADED\"", m);
+}
+
+// There isn't any point in adding a test which calls Accept() on the
+// ThreeDAPIInfoBarDelegate; doing so doesn't remove the infobar, and
+// there's no concrete event that could be observed in response.
+
IN_PROC_BROWSER_TEST_F(GPUCrashTest, WebkitLoseContext) {
content::DOMMessageQueue message_queue;
diff --git a/content/test/data/gpu/webgl.html b/content/test/data/gpu/webgl.html
index 38e3fab..18bed47 100644
--- a/content/test/data/gpu/webgl.html
+++ b/content/test/data/gpu/webgl.html
@@ -6,6 +6,8 @@ var w, h;
var gl;
var extension;
+var alreadySetAutomationId = false;
+
function testHorizontalBands() {
gl.enable(gl.SCISSOR_TEST);
@@ -48,7 +50,8 @@ function testContextRestored() {
var a = new Uint8Array(w * h * 4);
gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, a);
- window.domAutomationController.setAutomationId(1);
+ if (!alreadySetAutomationId)
+ window.domAutomationController.setAutomationId(1);
if (a[0] == 0 && a[1] == 0 && a[2] == 255)
window.domAutomationController.send("SUCCESS");
else
@@ -68,6 +71,13 @@ function contextLostTest(kind)
// nothing -- the browser test navigates to about:gpucrash and kills
// the GPU process.
break;
+ case "kill_after_notification":
+ // The browser test waits for notification from the page that it
+ // has been loaded before navigating to about:gpucrash.
+ window.domAutomationController.setAutomationId(1);
+ alreadySetAutomationId = true;
+ window.domAutomationController.send("LOADED");
+ break;
}
}