Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(905)

Unified Diff: ios/web/web_state/js/crw_js_window_id_manager_unittest.mm

Issue 1129763003: Re-enable JSWindowIDManagerTest.WindowID (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use web::EvaluateJavaScriptAsString Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/public/web_state/js/crw_js_window_id_manager_unittest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/js/crw_js_window_id_manager_unittest.mm
diff --git a/ios/web/public/web_state/js/crw_js_window_id_manager_unittest.mm b/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm
similarity index 75%
rename from ios/web/public/web_state/js/crw_js_window_id_manager_unittest.mm
rename to ios/web/web_state/js/crw_js_window_id_manager_unittest.mm
index 4abc76abdda1b41e179327ff3ff3147262ec8a47..bc4280d3310290fb30cc10484eb312d97cad8b07 100644
--- a/ios/web/public/web_state/js/crw_js_window_id_manager_unittest.mm
+++ b/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm
@@ -6,6 +6,7 @@
#include "base/mac/scoped_nsobject.h"
#import "ios/web/public/test/crw_test_js_injection_receiver.h"
+#import "ios/web/public/test/js_test_util.h"
#include "ios/web/public/web_client.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
@@ -33,19 +34,26 @@ class JSWindowIDManagerTest : public PlatformTest {
web::WebClient web_client_;
};
-// TODO(jyquinn): enable this test (crbug.com/465898).
-TEST_F(JSWindowIDManagerTest, DISABLED_WindowID) {
+// Tests that reinjection of window ID JS results in a different window ID.
+// TODO(ios): This test only works for the current implementation using
+// UIWebView. CRWTestJSInjectionReceiver should be re-written to eliminate
+// web view specificity (crbug.com/486840).
+TEST_F(JSWindowIDManagerTest, WindowIDReinjection) {
EXPECT_TRUE(manager_.get());
[manager_ inject];
NSString* windowID = [manager_ windowId];
EXPECT_EQ(32U, [windowID length]);
+ // Reset the __gCrWeb object to enable reinjection.
+ web::EvaluateJavaScriptAsString(manager_, @"__gCrWeb = undefined;");
// Inject a second time to check that the ID is different.
[manager_ inject];
NSString* windowID2 = [manager_ windowId];
EXPECT_FALSE([windowID isEqualToString:windowID2]);
}
-TEST_F(JSWindowIDManagerTest, WindowIDDifferent) {
+// Tests that window ID injection by a second manager results in a different
+// window ID.
+TEST_F(JSWindowIDManagerTest, WindowIDDifferentManager) {
[manager_ inject];
NSString* windowID = [manager_ windowId];
base::scoped_nsobject<CRWTestJSInjectionReceiver> receiver2(
« no previous file with comments | « ios/web/public/web_state/js/crw_js_window_id_manager_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698