diff options
author | slightlyoff@chromium.org <slightlyoff@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-10 03:16:31 +0000 |
---|---|---|
committer | slightlyoff@chromium.org <slightlyoff@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-10 03:16:31 +0000 |
commit | b6a040a170be44d208a5ab379931c571232dd3e2 (patch) | |
tree | b417055b805b6ad2358342008754e4f5d05976b1 /chrome_frame/test | |
parent | 2cdaa8386a9236316f80281e8b5c0023d1ce83ad (diff) | |
download | chromium_src-b6a040a170be44d208a5ab379931c571232dd3e2.zip chromium_src-b6a040a170be44d208a5ab379931c571232dd3e2.tar.gz chromium_src-b6a040a170be44d208a5ab379931c571232dd3e2.tar.bz2 |
Updates CFInstall.js to:
* provide a new 'overlay' prompt mode that includes a "close" button with a cookie that respects the user preference for any originating site
* handle requesting the install UI from a host page loaded from a file:// URL
* expands UA detection to stop taunting Win2K (and below) users with visions of WebKit goodness
* preserves full compat with previous version
BUG=23057,22738,23132
TEST=see new test files in this change or build chrome_frame_tests and run with: chrome_frame_tests.exe --gtest_filter=*CFInstall*
Review URL: http://codereview.chromium.org/345032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31539 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test')
-rw-r--r-- | chrome_frame/test/chrome_frame_unittests.cc | 25 | ||||
-rw-r--r-- | chrome_frame/test/data/CFInstall_basic.html | 41 | ||||
-rw-r--r-- | chrome_frame/test/data/CFInstall_dismiss.html | 53 | ||||
-rw-r--r-- | chrome_frame/test/data/CFInstall_overlay.html | 67 | ||||
-rw-r--r-- | chrome_frame/test/data/CFInstall_place.html | 74 | ||||
-rw-r--r-- | chrome_frame/test/data/chrome_frame_tester_helpers.js | 6 | ||||
-rw-r--r-- | chrome_frame/test/http_server.cc | 16 |
7 files changed, 281 insertions, 1 deletions
diff --git a/chrome_frame/test/chrome_frame_unittests.cc b/chrome_frame/test/chrome_frame_unittests.cc index 1845101..6472310 100644 --- a/chrome_frame/test/chrome_frame_unittests.cc +++ b/chrome_frame/test/chrome_frame_unittests.cc @@ -564,6 +564,31 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeFF_CFInstanceDefaultCtor) { SimpleBrowserTest(FIREFOX, kCFIDefaultCtorPage, L"CFInstanceDefaultCtor"); } + +const wchar_t kCFInstallBasicTestPage[] = L"files/CFInstall_basic.html"; + +TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallBasic) { + SimpleBrowserTest(IE, kCFInstallBasicTestPage, L"CFInstallBasic"); +} + +const wchar_t kCFInstallPlaceTestPage[] = L"files/CFInstall_place.html"; + +TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallPlace) { + SimpleBrowserTest(IE, kCFInstallPlaceTestPage, L"CFInstallPlace"); +} + +const wchar_t kCFInstallOverlayTestPage[] = L"files/CFInstall_overlay.html"; + +TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallOverlay) { + SimpleBrowserTest(IE, kCFInstallOverlayTestPage, L"CFInstallOverlay"); +} + +const wchar_t kCFInstallDismissTestPage[] = L"files/CFInstall_dismiss.html"; + +TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallDismiss) { + SimpleBrowserTest(IE, kCFInstallDismissTestPage, L"CFInstallDismiss"); +} + const wchar_t kInitializeHiddenPage[] = L"files/initialize_hidden.html"; TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_InitializeHidden) { diff --git a/chrome_frame/test/data/CFInstall_basic.html b/chrome_frame/test/data/CFInstall_basic.html new file mode 100644 index 0000000..bbf7006 --- /dev/null +++ b/chrome_frame/test/data/CFInstall_basic.html @@ -0,0 +1,41 @@ +<html> + <head> + <script type="text/javascript" + src="chrome_frame_tester_helpers.js"></script> + <script type="text/javascript" + src="CFInstall.js"></script> + </head> + <body> + <div id="statusPanel" style="border: 1px solid red; width: 100%"> + Test running.... + </div> + + <script type="text/javascript"> + var testName = 'CFInstallBasic'; + (function(){ + try{ + // Testing over-rides for GCF detection code. + CFInstall._force = true; + CFInstall._forceValue = false; + + CFInstall.check({ + // TODO(slightlyoff): popup window tests? + mode: 'inline' + }); + + if (document.body.firstChild.tagName != 'IFRAME') { + onFailure(testName, 1, 'prompt placed incorrectly'); + return; + } + + onSuccess(testName, 1); + + } catch (e) { + onFailure(testName, 1, + 'CFInstall basic test failed with error: '+e); + } + })(); + </script> + <p>Tests CFInstall basic prompt functionality</p> + </body> +</html> diff --git a/chrome_frame/test/data/CFInstall_dismiss.html b/chrome_frame/test/data/CFInstall_dismiss.html new file mode 100644 index 0000000..35e2f80 --- /dev/null +++ b/chrome_frame/test/data/CFInstall_dismiss.html @@ -0,0 +1,53 @@ +<html> + <head> + <script type="text/javascript" + src="chrome_frame_tester_helpers.js"></script> + <script type="text/javascript" + src="CFInstall.js"></script> + </head> + <body> + <div id="statusPanel" style="border: 1px solid red; width: 100%"> + Test running.... + </div> + + <script type="text/javascript"> + var testName = 'CFInstallDismiss'; + (function(){ + try{ + // Testing over-rides for GCF detection code. + CFInstall._force = true; + CFInstall._forceValue = false; + + // Clobber prompt supression cookie if set. + document.cookie = 'disableGCFCheck=0;path=/'; + + CFInstall.check({ + id: 'prompt', + mode: 'overlay' + }); + + var p = byId('prompt'); + + if (!p) { + onFailure(testName, 1, 'prompt not created with correct ID'); + return; + } + + byId('chromeFrameCloseButton').click(); + + if (document.cookie.indexOf('disableGCFCheck=1') == -1) { + onFailure(testName, 1, 'dismiss cookie not set'); + return; + } + + onSuccess(testName, 1); + + } catch (e) { + onFailure(testName, 1, + 'CFInstall overlay prompt failed with error: '+e); + } + })(); + </script> + <p>Tests CFInstall overlay prompt</p> + </body> +</html> diff --git a/chrome_frame/test/data/CFInstall_overlay.html b/chrome_frame/test/data/CFInstall_overlay.html new file mode 100644 index 0000000..1d17422 --- /dev/null +++ b/chrome_frame/test/data/CFInstall_overlay.html @@ -0,0 +1,67 @@ +<html> + <head> + <script type="text/javascript" + src="chrome_frame_tester_helpers.js"></script> + <script type="text/javascript" + src="CFInstall.js"></script> + </head> + <body> + <div id="statusPanel" style="border: 1px solid red; width: 100%"> + Test running.... + </div> + + <script type="text/javascript"> + var testName = 'CFInstallOverlay'; + (function(){ + try{ + // Testing over-rides for GCF detection code. + CFInstall._force = true; + CFInstall._forceValue = false; + + // Clobber prompt supression cookie if set. + document.cookie = 'disableGCFCheck=0;path=/'; + + CFInstall.check({ + id: 'prompt', + mode: 'overlay' + }); + + var p = byId('prompt'); + + if (!p) { + onFailure(testName, 1, 'prompt not created with correct ID'); + return; + } + + // Make sure the prompt is parented in the display table. + if (p.parentNode != byId('chromeFrameIframeHolder')) { + onFailure(testName, 1, 'prompt not parented correctly'); + return; + } + + var lc = document.body.lastChild; + + if (lc.nodeType != 1 || !lc.firstChild && + lc.firstChild != byId('chromeFrameOverlayUnderlay')) { + onFailure(testName, 1, 'underlay placed incorrectly'); + return; + } + + if (lc.nodeType != 1 || !lc.firstChild && + lc.firstChild.nextSibling != byId('chromeFrameOverlayContent')) { + onFailure(testName, 1, 'prompt placed incorrectly'); + return; + } + + onSuccess(testName, 1); + + } catch (e) { + onFailure(testName, 1, + 'CFInstall overlay prompt failed with error: '+e); + } + })(); + </script> + <p>Tests CFInstall overlay prompt</p> + </body> +</html> + diff --git a/chrome_frame/test/data/CFInstall_place.html b/chrome_frame/test/data/CFInstall_place.html new file mode 100644 index 0000000..a8e543b --- /dev/null +++ b/chrome_frame/test/data/CFInstall_place.html @@ -0,0 +1,74 @@ +<html> + <head> + <script type="text/javascript" + src="chrome_frame_tester_helpers.js"></script> + <script type="text/javascript" + src="CFInstall.js"></script> + </head> + <body> + <div id="statusPanel" style="border: 1px solid red; width: 100%"> + Test running.... + </div> + + <div id="parent"> + <div id="prev">before</div><div id="toBeReplaced"> + fallback content goes here + </div><div id="after">after</div> + </div> + <script type="text/javascript"> + var testName = 'CFInstallPlace'; + (function(){ + try{ + // Testing over-rides for GCF detection code. + CFInstall._force = true; + CFInstall._forceValue = false; + + CFInstall.check({ + node: 'toBeReplaced', + id: 'prompt', + cssText: 'width: 400px; height: 300px;', + mode: 'inline' + }); + + var p = byId('prompt'); + + if (!p) { + onFailure(testName, 1, 'prompt not created with correct ID'); + return; + } + + var fc = document.body.firstChild; + + if (fc.nodeType == 1 && fc.tagName == 'IFRAME') { + onFailure(testName, 1, 'prompt placed incorrectly'); + return; + } + + if (p.tagName != 'IFRAME') { + onFailure(testName, 1, 'prompt has wrong tag type'); + return; + } + + // Ensure that it got dropped into the right bit of the DOM + if (byId('prev').nextSibling != p) { + onFailure(testName, 1, 'prompt placed incorrectly'); + return; + } + + // Make sure that the geometry took. + if (p.style.width != '400px') { + onFailure(testName, 1, 'prompt sized incorrectly'); + return; + } + + onSuccess(testName, 1); + + } catch (e) { + onFailure(testName, 1, + 'CFInstall placement failed with error: '+e); + } + })(); + </script> + <p>Tests CFInstall prompt placement</p> + </body> +</html> diff --git a/chrome_frame/test/data/chrome_frame_tester_helpers.js b/chrome_frame/test/data/chrome_frame_tester_helpers.js index e18ab87..e7f2a83 100644 --- a/chrome_frame/test/data/chrome_frame_tester_helpers.js +++ b/chrome_frame/test/data/chrome_frame_tester_helpers.js @@ -9,6 +9,10 @@ function onFailure(name, id, status) { onFinished(name, id, status); } +function byId(id) { + return document.getElementById(id); +} + function getXHRObject(){ var XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; @@ -91,7 +95,7 @@ function onFinished(name, id, result) { } function appendStatus(message) { - var statusPanel = document.getElementById("statusPanel"); + var statusPanel = byId("statusPanel"); if (statusPanel) { statusPanel.innerHTML += '<BR>' + message; } diff --git a/chrome_frame/test/http_server.cc b/chrome_frame/test/http_server.cc index f2cc333..d8223f2 100644 --- a/chrome_frame/test/http_server.cc +++ b/chrome_frame/test/http_server.cc @@ -20,6 +20,12 @@ void ChromeFrameHTTPServer::SetUp() { FILE_PATH_LITERAL("test")).Append( FILE_PATH_LITERAL("data")).Append( FILE_PATH_LITERAL("CFInstance.js"))); // NOLINT + + file_util::CopyFile(cf_source_path.Append(FILE_PATH_LITERAL("CFInstall.js")), + cf_source_path.Append( + FILE_PATH_LITERAL("test")).Append( + FILE_PATH_LITERAL("data")).Append( + FILE_PATH_LITERAL("CFInstall.js"))); // NOLINT } void ChromeFrameHTTPServer::TearDown() { @@ -37,6 +43,16 @@ void ChromeFrameHTTPServer::TearDown() { .Append(FILE_PATH_LITERAL("CFInstance.js")); file_util::Delete(cfi_path, false); + + cfi_path.empty(); + PathService::Get(base::DIR_SOURCE_ROOT, &cfi_path); + cfi_path = cfi_path + .Append(FILE_PATH_LITERAL("chrome_frame")) + .Append(FILE_PATH_LITERAL("test")) + .Append(FILE_PATH_LITERAL("data")) + .Append(FILE_PATH_LITERAL("CFInstall.js")); + + file_util::Delete(cfi_path, false); } bool ChromeFrameHTTPServer::WaitToFinish(int milliseconds) { |