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

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 1166493003: Prevent reentrancy of WebFrameClient::didClearWindowObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fxied android compile Created 5 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/FrameLoader.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); 404 webViewHelper.initializeAndLoad(m_baseURL + fileName, true);
405 405
406 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip t:location.port = ''; void 0;"); 406 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip t:location.port = ''; void 0;");
407 407
408 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip t:document.body.textContent = location.href; void 0;"); 408 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip t:document.body.textContent = location.href; void 0;");
409 409
410 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10 24).utf8(); 410 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10 24).utf8();
411 EXPECT_EQ("http://internal.test:0/" + fileName, content); 411 EXPECT_EQ("http://internal.test:0/" + fileName, content);
412 } 412 }
413 413
414 class EvaluateOnLoadWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
415 public:
416 EvaluateOnLoadWebFrameClient() : m_executing(false), m_wasExecuted(false) { }
417
418 void didClearWindowObject(WebLocalFrame* frame) override
419 {
420 EXPECT_FALSE(m_executing);
421 m_wasExecuted = true;
422 m_executing = true;
423 v8::HandleScope handleScope(v8::Isolate::GetCurrent());
424 frame->executeScriptAndReturnValue(WebScriptSource(WebString("window.som eProperty = 42;")));
425 m_executing = false;
426 }
427
428 bool m_executing;
429 bool m_wasExecuted;
430 };
431
432 TEST_P(ParametrizedWebFrameTest, DidClearWindowObjectIsNotRecursive)
433 {
434 EvaluateOnLoadWebFrameClient webFrameClient;
435 FrameTestHelpers::WebViewHelper webViewHelper(this);
436 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient);
437 EXPECT_TRUE(webFrameClient.m_wasExecuted);
438 }
439
414 class CSSCallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 440 class CSSCallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
415 public: 441 public:
416 CSSCallbackWebFrameClient() : m_updateCount(0) { } 442 CSSCallbackWebFrameClient() : m_updateCount(0) { }
417 virtual void didMatchCSS(WebLocalFrame*, const WebVector<WebString>& newlyMa tchingSelectors, const WebVector<WebString>& stoppedMatchingSelectors) override; 443 virtual void didMatchCSS(WebLocalFrame*, const WebVector<WebString>& newlyMa tchingSelectors, const WebVector<WebString>& stoppedMatchingSelectors) override;
418 444
419 std::map<WebLocalFrame*, std::set<std::string>> m_matchedSelectors; 445 std::map<WebLocalFrame*, std::set<std::string>> m_matchedSelectors;
420 int m_updateCount; 446 int m_updateCount;
421 }; 447 };
422 448
423 void CSSCallbackWebFrameClient::didMatchCSS(WebLocalFrame* frame, const WebVecto r<WebString>& newlyMatchingSelectors, const WebVector<WebString>& stoppedMatchin gSelectors) 449 void CSSCallbackWebFrameClient::didMatchCSS(WebLocalFrame* frame, const WebVecto r<WebString>& newlyMatchingSelectors, const WebVector<WebString>& stoppedMatchin gSelectors)
(...skipping 6981 matching lines...) Expand 10 before | Expand all | Expand 10 after
7405 7431
7406 EXPECT_EQ(parent, firstFrame->parent()); 7432 EXPECT_EQ(parent, firstFrame->parent());
7407 EXPECT_EQ(parent, secondFrame->parent()); 7433 EXPECT_EQ(parent, secondFrame->parent());
7408 EXPECT_EQ(parent, thirdFrame->parent()); 7434 EXPECT_EQ(parent, thirdFrame->parent());
7409 EXPECT_EQ(parent, fourthFrame->parent()); 7435 EXPECT_EQ(parent, fourthFrame->parent());
7410 7436
7411 view->close(); 7437 view->close();
7412 } 7438 }
7413 7439
7414 } // namespace blink 7440 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/FrameLoader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698