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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 1917073002: Block webpages from navigating to view-source URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete layout tests Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 }; 456 };
457 457
458 // Helper function to focus a frame by sending it a mouse click and then 458 // Helper function to focus a frame by sending it a mouse click and then
459 // waiting for it to become focused. 459 // waiting for it to become focused.
460 void FocusFrame(FrameTreeNode* frame) { 460 void FocusFrame(FrameTreeNode* frame) {
461 FrameFocusedObserver focus_observer(frame); 461 FrameFocusedObserver focus_observer(frame);
462 SimulateMouseClick(frame->current_frame_host()->GetRenderWidgetHost(), 1, 1); 462 SimulateMouseClick(frame->current_frame_host()->GetRenderWidgetHost(), 1, 1);
463 focus_observer.Wait(); 463 focus_observer.Wait();
464 } 464 }
465 465
466 // A WebContentsDelegate that catches messages sent to the console.
467 class ConsoleObserverDelegate : public WebContentsDelegate {
468 public:
469 ConsoleObserverDelegate(WebContents* web_contents, const std::string& filter)
470 : web_contents_(web_contents),
471 filter_(filter),
472 message_(""),
473 message_loop_runner_(new MessageLoopRunner) {}
474
475 ~ConsoleObserverDelegate() override {}
476
477 bool AddMessageToConsole(WebContents* source,
478 int32_t level,
479 const base::string16& message,
480 int32_t line_no,
481 const base::string16& source_id) override;
482
483 std::string message() { return message_; }
484
485 void Wait();
486
487 private:
488 WebContents* web_contents_;
489 std::string filter_;
490 std::string message_;
491
492 // The MessageLoopRunner used to spin the message loop.
493 scoped_refptr<MessageLoopRunner> message_loop_runner_;
494
495 DISALLOW_COPY_AND_ASSIGN(ConsoleObserverDelegate);
496 };
497
498 void ConsoleObserverDelegate::Wait() {
499 message_loop_runner_->Run();
500 }
501
502 bool ConsoleObserverDelegate::AddMessageToConsole(
503 WebContents* source,
504 int32_t level,
505 const base::string16& message,
506 int32_t line_no,
507 const base::string16& source_id) {
508 DCHECK(source == web_contents_);
509
510 std::string ascii_message = base::UTF16ToASCII(message);
511 if (base::MatchPattern(ascii_message, filter_)) {
512 message_ = ascii_message;
513 message_loop_runner_->Quit();
514 }
515 return false;
516 }
517
518 // A BrowserMessageFilter that drops SwapOut ACK messages. 466 // A BrowserMessageFilter that drops SwapOut ACK messages.
519 class SwapoutACKMessageFilter : public BrowserMessageFilter { 467 class SwapoutACKMessageFilter : public BrowserMessageFilter {
520 public: 468 public:
521 SwapoutACKMessageFilter() : BrowserMessageFilter(FrameMsgStart) {} 469 SwapoutACKMessageFilter() : BrowserMessageFilter(FrameMsgStart) {}
522 470
523 protected: 471 protected:
524 ~SwapoutACKMessageFilter() override {} 472 ~SwapoutACKMessageFilter() override {}
525 473
526 private: 474 private:
527 // BrowserMessageFilter: 475 // BrowserMessageFilter:
(...skipping 6695 matching lines...) Expand 10 before | Expand all | Expand 10 after
7223 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0))); 7171 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)));
7224 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); 7172 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7225 7173
7226 // Cross-site navigation should preserve the fullscreen flags. 7174 // Cross-site navigation should preserve the fullscreen flags.
7227 NavigateFrameToURL(root->child_at(0)->child_at(0), 7175 NavigateFrameToURL(root->child_at(0)->child_at(0),
7228 embedded_test_server()->GetURL("d.com", "/title1.html")); 7176 embedded_test_server()->GetURL("d.com", "/title1.html"));
7229 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); 7177 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7230 } 7178 }
7231 7179
7232 } // namespace content 7180 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698