Commit 7745012e authored by jyquinn's avatar jyquinn Committed by Commit bot

Re-enable JSWindowIDManagerTest.WindowID

Creates CRWTestJSWindowIdManager to enable force injection,
bypassing hasBeenInjected check in the inject method.

Moves crw_js_window_id_manager_unittest.mm out of public directory.

BUG=465898

Review URL: https://codereview.chromium.org/1129763003

Cr-Commit-Position: refs/heads/master@{#329438}
parent 9d93b73c
......@@ -41,7 +41,6 @@
'net/web_http_protocol_handler_delegate_unittest.mm',
'public/referrer_util_unittest.cc',
'public/test/http_server_unittest.mm',
'public/web_state/js/crw_js_window_id_manager_unittest.mm',
'string_util_unittest.cc',
'test/crw_fake_web_controller_observer_unittest.mm',
'test/run_all_unittests.cc',
......@@ -55,6 +54,7 @@
'web_state/js/crw_js_early_script_manager_unittest.mm',
'web_state/js/crw_js_injection_manager_unittest.mm',
'web_state/js/crw_js_invoke_parameter_queue_unittest.mm',
'web_state/js/crw_js_window_id_manager_unittest.mm',
'web_state/js/page_script_util_unittest.mm',
'web_state/ui/crw_static_file_web_view_unittest.mm',
'web_state/ui/crw_ui_simple_web_view_controller_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(
......
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