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

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

Issue 1167343002: Add methods for creating V8 extras-based ReadableStreams from C++ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove C++ queuing strategies 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 #include "core/loader/HistoryItem.h" 110 #include "core/loader/HistoryItem.h"
111 #include "core/page/ChromeClient.h" 111 #include "core/page/ChromeClient.h"
112 #include "core/page/EventHandler.h" 112 #include "core/page/EventHandler.h"
113 #include "core/page/FocusController.h" 113 #include "core/page/FocusController.h"
114 #include "core/page/NetworkStateNotifier.h" 114 #include "core/page/NetworkStateNotifier.h"
115 #include "core/page/Page.h" 115 #include "core/page/Page.h"
116 #include "core/page/PrintContext.h" 116 #include "core/page/PrintContext.h"
117 #include "core/paint/DeprecatedPaintLayer.h" 117 #include "core/paint/DeprecatedPaintLayer.h"
118 #include "core/plugins/testing/DictionaryPluginPlaceholder.h" 118 #include "core/plugins/testing/DictionaryPluginPlaceholder.h"
119 #include "core/plugins/testing/DocumentFragmentPluginPlaceholder.h" 119 #include "core/plugins/testing/DocumentFragmentPluginPlaceholder.h"
120 #include "core/streams/ReadableStream2.h"
120 #include "core/testing/DictionaryTest.h" 121 #include "core/testing/DictionaryTest.h"
121 #include "core/testing/GCObservation.h" 122 #include "core/testing/GCObservation.h"
122 #include "core/testing/InternalRuntimeFlags.h" 123 #include "core/testing/InternalRuntimeFlags.h"
123 #include "core/testing/InternalSettings.h" 124 #include "core/testing/InternalSettings.h"
124 #include "core/testing/LayerRect.h" 125 #include "core/testing/LayerRect.h"
125 #include "core/testing/LayerRectList.h" 126 #include "core/testing/LayerRectList.h"
126 #include "core/testing/PluginPlaceholderOptions.h" 127 #include "core/testing/PluginPlaceholderOptions.h"
127 #include "core/testing/PrivateScriptTest.h" 128 #include "core/testing/PrivateScriptTest.h"
128 #include "core/testing/TypeConversions.h" 129 #include "core/testing/TypeConversions.h"
129 #include "core/testing/UnionTypesTest.h" 130 #include "core/testing/UnionTypesTest.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 186
186 static SpellCheckRequester* spellCheckRequester(Document* document) 187 static SpellCheckRequester* spellCheckRequester(Document* document)
187 { 188 {
188 if (!document || !document->frame()) 189 if (!document || !document->frame())
189 return 0; 190 return 0;
190 return &document->frame()->spellChecker().spellCheckRequester(); 191 return &document->frame()->spellChecker().spellCheckRequester();
191 } 192 }
192 193
193 const char* Internals::internalsId = "internals"; 194 const char* Internals::internalsId = "internals";
194 195
195 Internals* Internals::create(Document* document) 196 Internals* Internals::create(ScriptState* scriptState)
196 { 197 {
197 return new Internals(document); 198 return new Internals(scriptState);
198 } 199 }
199 200
200 Internals::~Internals() 201 Internals::~Internals()
201 { 202 {
202 } 203 }
203 204
204 void Internals::resetToConsistentState(Page* page) 205 void Internals::resetToConsistentState(Page* page)
205 { 206 {
206 ASSERT(page); 207 ASSERT(page);
207 208
208 page->setDeviceScaleFactor(1); 209 page->setDeviceScaleFactor(1);
209 page->setIsCursorVisible(true); 210 page->setIsCursorVisible(true);
210 page->setPageScaleFactor(1, IntPoint(0, 0)); 211 page->setPageScaleFactor(1, IntPoint(0, 0));
211 overrideUserPreferredLanguages(Vector<AtomicString>()); 212 overrideUserPreferredLanguages(Vector<AtomicString>());
212 if (!page->deprecatedLocalMainFrame()->spellChecker().isContinuousSpellCheck ingEnabled()) 213 if (!page->deprecatedLocalMainFrame()->spellChecker().isContinuousSpellCheck ingEnabled())
213 page->deprecatedLocalMainFrame()->spellChecker().toggleContinuousSpellCh ecking(); 214 page->deprecatedLocalMainFrame()->spellChecker().toggleContinuousSpellCh ecking();
214 if (page->deprecatedLocalMainFrame()->editor().isOverwriteModeEnabled()) 215 if (page->deprecatedLocalMainFrame()->editor().isOverwriteModeEnabled())
215 page->deprecatedLocalMainFrame()->editor().toggleOverwriteModeEnabled(); 216 page->deprecatedLocalMainFrame()->editor().toggleOverwriteModeEnabled();
216 217
217 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator( )) 218 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator( ))
218 scrollingCoordinator->reset(); 219 scrollingCoordinator->reset();
219 220
220 page->deprecatedLocalMainFrame()->view()->clear(); 221 page->deprecatedLocalMainFrame()->view()->clear();
221 } 222 }
222 223
223 Internals::Internals(Document* document) 224 namespace {
224 : ContextLifecycleObserver(document) 225
226 class TestUnderlyingSource : public UnderlyingSourceBase {
227 public:
228 ScriptPromise start(ScriptState* scriptState) override
229 {
230 controller().enqueue("a");
231 controller().enqueue("b");
232 controller().close();
233 return UnderlyingSourceBase::start(scriptState);
234 };
235 };
236
237 } // namespace
238
239 Internals::Internals(ScriptState* scriptState)
240 : ContextLifecycleObserver(scriptState->executionContext())
225 , m_runtimeFlags(InternalRuntimeFlags::create()) 241 , m_runtimeFlags(InternalRuntimeFlags::create())
242 , m_readableStream(new ReadableStream2(scriptState, new TestUnderlyingSource (),
243 ReadableStream2::createCountQueuingStrategy(scriptState, 1024.0)))
226 { 244 {
227 } 245 }
228 246
229 Document* Internals::contextDocument() const 247 Document* Internals::contextDocument() const
230 { 248 {
231 return toDocument(executionContext()); 249 return toDocument(executionContext());
232 } 250 }
233 251
234 LocalFrame* Internals::frame() const 252 LocalFrame* Internals::frame() const
235 { 253 {
(...skipping 2127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 } 2381 }
2364 2382
2365 ClientRectList* Internals::focusRingRects(Element* element) 2383 ClientRectList* Internals::focusRingRects(Element* element)
2366 { 2384 {
2367 Vector<LayoutRect> rects; 2385 Vector<LayoutRect> rects;
2368 if (element && element->layoutObject()) 2386 if (element && element->layoutObject())
2369 element->layoutObject()->addFocusRingRects(rects, LayoutPoint()); 2387 element->layoutObject()->addFocusRingRects(rects, LayoutPoint());
2370 return ClientRectList::create(rects); 2388 return ClientRectList::create(rects);
2371 } 2389 }
2372 2390
2391 ScriptValue Internals::readableStream()
2392 {
2393 return m_readableStream->scriptValue();
2394 }
2395
2373 } // namespace blink 2396 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698