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

Side by Side Diff: Source/core/testing/MockPagePopupDriver.cpp

Issue 120513004: Don't expose DocumentWriter to embedding layer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 12 matching lines...) Expand all
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "MockPagePopupDriver.h" 27 #include "MockPagePopupDriver.h"
28 28
29 #include "CSSPropertyNames.h" 29 #include "CSSPropertyNames.h"
30 #include "CSSValueKeywords.h" 30 #include "CSSValueKeywords.h"
31 #include "bindings/v8/ExceptionStatePlaceholder.h" 31 #include "bindings/v8/ExceptionStatePlaceholder.h"
32 #include "core/html/HTMLIFrameElement.h" 32 #include "core/html/HTMLIFrameElement.h"
33 #include "core/loader/DocumentLoader.h" 33 #include "core/loader/FrameLoadRequest.h"
34 #include "core/loader/DocumentWriter.h"
35 #include "core/loader/FrameLoader.h" 34 #include "core/loader/FrameLoader.h"
36 #include "core/frame/Frame.h" 35 #include "core/frame/Frame.h"
37 #include "core/page/PagePopup.h" 36 #include "core/page/PagePopup.h"
38 #include "core/page/PagePopupController.h" 37 #include "core/page/PagePopupController.h"
39 #include "platform/Timer.h" 38 #include "platform/Timer.h"
40 39
41 namespace WebCore { 40 namespace WebCore {
42 41
43 class MockPagePopup : public PagePopup, public RefCounted<MockPagePopup> { 42 class MockPagePopup : public PagePopup, public RefCounted<MockPagePopup> {
44 public: 43 public:
(...skipping 17 matching lines...) Expand all
62 Document* document = mainFrame->document(); 61 Document* document = mainFrame->document();
63 ASSERT(document); 62 ASSERT(document);
64 m_iframe = HTMLIFrameElement::create(*document); 63 m_iframe = HTMLIFrameElement::create(*document);
65 m_iframe->setIdAttribute("mock-page-popup"); 64 m_iframe->setIdAttribute("mock-page-popup");
66 m_iframe->setInlineStyleProperty(CSSPropertyBorderWidth, 0.0, CSSPrimitiveVa lue::CSS_PX); 65 m_iframe->setInlineStyleProperty(CSSPropertyBorderWidth, 0.0, CSSPrimitiveVa lue::CSS_PX);
67 m_iframe->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute); 66 m_iframe->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
68 m_iframe->setInlineStyleProperty(CSSPropertyLeft, originBoundsInRootView.x() , CSSPrimitiveValue::CSS_PX, true); 67 m_iframe->setInlineStyleProperty(CSSPropertyLeft, originBoundsInRootView.x() , CSSPrimitiveValue::CSS_PX, true);
69 m_iframe->setInlineStyleProperty(CSSPropertyTop, originBoundsInRootView.maxY (), CSSPrimitiveValue::CSS_PX, true); 68 m_iframe->setInlineStyleProperty(CSSPropertyTop, originBoundsInRootView.maxY (), CSSPrimitiveValue::CSS_PX, true);
70 if (document->body()) 69 if (document->body())
71 document->body()->appendChild(m_iframe.get()); 70 document->body()->appendChild(m_iframe.get());
72 Frame* contentFrame = m_iframe->contentFrame();
73 DocumentWriter* writer = contentFrame->loader().documentLoader()->beginWriti ng("text/html", "UTF-8");
74 const char scriptToSetUpPagePopupController[] = "<script>window.pagePopupCon troller = parent.internals.pagePopupController;</script>"; 71 const char scriptToSetUpPagePopupController[] = "<script>window.pagePopupCon troller = parent.internals.pagePopupController;</script>";
75 writer->addData(scriptToSetUpPagePopupController, sizeof(scriptToSetUpPagePo pupController)); 72 RefPtr<SharedBuffer> data = SharedBuffer::create(scriptToSetUpPagePopupContr oller, sizeof(scriptToSetUpPagePopupController));
76 m_popupClient->writeDocument(*writer); 73 m_popupClient->writeDocument(data.get());
77 contentFrame->loader().documentLoader()->endWriting(writer); 74 m_iframe->contentFrame()->loader().load(FrameLoadRequest(0, blankURL(), Subs tituteData(data, "text/html", "UTF-8", KURL(), ForceSynchronousLoad)));
78 } 75 }
79 76
80 PassRefPtr<MockPagePopup> MockPagePopup::create(PagePopupClient* client, const I ntRect& originBoundsInRootView, Frame* mainFrame) 77 PassRefPtr<MockPagePopup> MockPagePopup::create(PagePopupClient* client, const I ntRect& originBoundsInRootView, Frame* mainFrame)
81 { 78 {
82 return adoptRef(new MockPagePopup(client, originBoundsInRootView, mainFrame) ); 79 return adoptRef(new MockPagePopup(client, originBoundsInRootView, mainFrame) );
83 } 80 }
84 81
85 void MockPagePopup::closeLater() 82 void MockPagePopup::closeLater()
86 { 83 {
87 ref(); 84 ref();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 { 130 {
134 if (!popup || popup != m_mockPagePopup.get()) 131 if (!popup || popup != m_mockPagePopup.get())
135 return; 132 return;
136 m_mockPagePopup->closeLater(); 133 m_mockPagePopup->closeLater();
137 m_mockPagePopup.clear(); 134 m_mockPagePopup.clear();
138 m_pagePopupController->clearPagePopupClient(); 135 m_pagePopupController->clearPagePopupClient();
139 m_pagePopupController.clear(); 136 m_pagePopupController.clear();
140 } 137 }
141 138
142 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698