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

Side by Side Diff: content/shell/renderer/test_runner/test_runner.cc

Issue 1052123002: Remove stylesheet injection bindings for test runner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 8 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
« no previous file with comments | « content/shell/renderer/test_runner/test_runner.h ('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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/shell/renderer/test_runner/test_runner.h" 5 #include "content/shell/renderer/test_runner/test_runner.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/public/test/layouttest_support.h" 10 #include "content/public/test/layouttest_support.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 void AddOriginAccessWhitelistEntry(const std::string& source_origin, 180 void AddOriginAccessWhitelistEntry(const std::string& source_origin,
181 const std::string& destination_protocol, 181 const std::string& destination_protocol,
182 const std::string& destination_host, 182 const std::string& destination_host,
183 bool allow_destination_subdomains); 183 bool allow_destination_subdomains);
184 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin, 184 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin,
185 const std::string& destination_protocol, 185 const std::string& destination_protocol,
186 const std::string& destination_host, 186 const std::string& destination_host,
187 bool allow_destination_subdomains); 187 bool allow_destination_subdomains);
188 bool HasCustomPageSizeStyle(int page_index); 188 bool HasCustomPageSizeStyle(int page_index);
189 void ForceRedSelectionColors(); 189 void ForceRedSelectionColors();
190 void InjectStyleSheet(const std::string& source_code, bool all_frames);
191 void InsertStyleSheet(const std::string& source_code); 190 void InsertStyleSheet(const std::string& source_code);
192 bool FindString(const std::string& search_text, 191 bool FindString(const std::string& search_text,
193 const std::vector<std::string>& options_array); 192 const std::vector<std::string>& options_array);
194 std::string SelectionAsMarkup(); 193 std::string SelectionAsMarkup();
195 void SetTextSubpixelPositioning(bool value); 194 void SetTextSubpixelPositioning(bool value);
196 void SetPageVisibility(const std::string& new_visibility); 195 void SetPageVisibility(const std::string& new_visibility);
197 void SetTextDirection(const std::string& direction_name); 196 void SetTextDirection(const std::string& direction_name);
198 void UseUnfortunateSynchronousResizeMode(); 197 void UseUnfortunateSynchronousResizeMode();
199 bool EnableAutoResizeMode(int min_width, 198 bool EnableAutoResizeMode(int min_width,
200 int min_height, 199 int min_height,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 .SetMethod("setIsolatedWorldContentSecurityPolicy", 387 .SetMethod("setIsolatedWorldContentSecurityPolicy",
389 &TestRunnerBindings::SetIsolatedWorldContentSecurityPolicy) 388 &TestRunnerBindings::SetIsolatedWorldContentSecurityPolicy)
390 .SetMethod("addOriginAccessWhitelistEntry", 389 .SetMethod("addOriginAccessWhitelistEntry",
391 &TestRunnerBindings::AddOriginAccessWhitelistEntry) 390 &TestRunnerBindings::AddOriginAccessWhitelistEntry)
392 .SetMethod("removeOriginAccessWhitelistEntry", 391 .SetMethod("removeOriginAccessWhitelistEntry",
393 &TestRunnerBindings::RemoveOriginAccessWhitelistEntry) 392 &TestRunnerBindings::RemoveOriginAccessWhitelistEntry)
394 .SetMethod("hasCustomPageSizeStyle", 393 .SetMethod("hasCustomPageSizeStyle",
395 &TestRunnerBindings::HasCustomPageSizeStyle) 394 &TestRunnerBindings::HasCustomPageSizeStyle)
396 .SetMethod("forceRedSelectionColors", 395 .SetMethod("forceRedSelectionColors",
397 &TestRunnerBindings::ForceRedSelectionColors) 396 &TestRunnerBindings::ForceRedSelectionColors)
398 .SetMethod("injectStyleSheet", &TestRunnerBindings::InjectStyleSheet)
399 .SetMethod("insertStyleSheet", &TestRunnerBindings::InsertStyleSheet) 397 .SetMethod("insertStyleSheet", &TestRunnerBindings::InsertStyleSheet)
400 .SetMethod("findString", &TestRunnerBindings::FindString) 398 .SetMethod("findString", &TestRunnerBindings::FindString)
401 .SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup) 399 .SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup)
402 .SetMethod("setTextSubpixelPositioning", 400 .SetMethod("setTextSubpixelPositioning",
403 &TestRunnerBindings::SetTextSubpixelPositioning) 401 &TestRunnerBindings::SetTextSubpixelPositioning)
404 .SetMethod("setPageVisibility", &TestRunnerBindings::SetPageVisibility) 402 .SetMethod("setPageVisibility", &TestRunnerBindings::SetPageVisibility)
405 .SetMethod("setTextDirection", &TestRunnerBindings::SetTextDirection) 403 .SetMethod("setTextDirection", &TestRunnerBindings::SetTextDirection)
406 .SetMethod("useUnfortunateSynchronousResizeMode", 404 .SetMethod("useUnfortunateSynchronousResizeMode",
407 &TestRunnerBindings::UseUnfortunateSynchronousResizeMode) 405 &TestRunnerBindings::UseUnfortunateSynchronousResizeMode)
408 .SetMethod("enableAutoResizeMode", 406 .SetMethod("enableAutoResizeMode",
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 if (runner_) 788 if (runner_)
791 return runner_->HasCustomPageSizeStyle(page_index); 789 return runner_->HasCustomPageSizeStyle(page_index);
792 return false; 790 return false;
793 } 791 }
794 792
795 void TestRunnerBindings::ForceRedSelectionColors() { 793 void TestRunnerBindings::ForceRedSelectionColors() {
796 if (runner_) 794 if (runner_)
797 runner_->ForceRedSelectionColors(); 795 runner_->ForceRedSelectionColors();
798 } 796 }
799 797
800 void TestRunnerBindings::InjectStyleSheet(const std::string& source_code,
801 bool all_frames) {
802 if (runner_)
803 runner_->InjectStyleSheet(source_code, all_frames);
804 }
805
806 void TestRunnerBindings::InsertStyleSheet(const std::string& source_code) { 798 void TestRunnerBindings::InsertStyleSheet(const std::string& source_code) {
807 if (runner_) 799 if (runner_)
808 runner_->InsertStyleSheet(source_code); 800 runner_->InsertStyleSheet(source_code);
809 } 801 }
810 802
811 bool TestRunnerBindings::FindString( 803 bool TestRunnerBindings::FindString(
812 const std::string& search_text, 804 const std::string& search_text,
813 const std::vector<std::string>& options_array) { 805 const std::vector<std::string>& options_array) {
814 if (runner_) 806 if (runner_)
815 return runner_->FindString(search_text, options_array); 807 return runner_->FindString(search_text, options_array);
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 if (web_view_) { 1606 if (web_view_) {
1615 web_view_->setZoomLevel(0); 1607 web_view_->setZoomLevel(0);
1616 web_view_->setTextZoomFactor(1); 1608 web_view_->setTextZoomFactor(1);
1617 web_view_->setTabKeyCyclesThroughElements(true); 1609 web_view_->setTabKeyCyclesThroughElements(true);
1618 #if !defined(__APPLE__) && !defined(WIN32) // Actually, TOOLKIT_GTK 1610 #if !defined(__APPLE__) && !defined(WIN32) // Actually, TOOLKIT_GTK
1619 // (Constants copied because we can't depend on the header that defined 1611 // (Constants copied because we can't depend on the header that defined
1620 // them from this file.) 1612 // them from this file.)
1621 web_view_->setSelectionColors( 1613 web_view_->setSelectionColors(
1622 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232); 1614 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232);
1623 #endif 1615 #endif
1624 web_view_->removeInjectedStyleSheets();
1625 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true); 1616 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true);
1626 web_view_->mainFrame()->enableViewSourceMode(false); 1617 web_view_->mainFrame()->enableViewSourceMode(false);
1627 1618
1628 if (page_overlay_) { 1619 if (page_overlay_) {
1629 web_view_->removePageOverlay(page_overlay_); 1620 web_view_->removePageOverlay(page_overlay_);
1630 delete page_overlay_; 1621 delete page_overlay_;
1631 page_overlay_ = nullptr; 1622 page_overlay_ = nullptr;
1632 } 1623 }
1633 } 1624 }
1634 1625
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
2266 WebFrame* frame = web_view_->mainFrame(); 2257 WebFrame* frame = web_view_->mainFrame();
2267 if (!frame) 2258 if (!frame)
2268 return false; 2259 return false;
2269 return frame->hasCustomPageSizeStyle(page_index); 2260 return frame->hasCustomPageSizeStyle(page_index);
2270 } 2261 }
2271 2262
2272 void TestRunner::ForceRedSelectionColors() { 2263 void TestRunner::ForceRedSelectionColors() {
2273 web_view_->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000, 0xffc0c0c0); 2264 web_view_->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000, 0xffc0c0c0);
2274 } 2265 }
2275 2266
2276 void TestRunner::InjectStyleSheet(const std::string& source_code,
2277 bool all_frames) {
2278 WebView::injectStyleSheet(
2279 WebString::fromUTF8(source_code),
2280 WebVector<WebString>(),
2281 all_frames ? WebView::InjectStyleInAllFrames
2282 : WebView::InjectStyleInTopFrameOnly);
2283 }
2284
2285 void TestRunner::InsertStyleSheet(const std::string& source_code) { 2267 void TestRunner::InsertStyleSheet(const std::string& source_code) {
2286 WebLocalFrame::frameForCurrentContext()->document().insertStyleSheet( 2268 WebLocalFrame::frameForCurrentContext()->document().insertStyleSheet(
2287 WebString::fromUTF8(source_code)); 2269 WebString::fromUTF8(source_code));
2288 } 2270 }
2289 2271
2290 bool TestRunner::FindString(const std::string& search_text, 2272 bool TestRunner::FindString(const std::string& search_text,
2291 const std::vector<std::string>& options_array) { 2273 const std::vector<std::string>& options_array) {
2292 WebFindOptions find_options; 2274 WebFindOptions find_options;
2293 bool wrap_around = false; 2275 bool wrap_around = false;
2294 find_options.matchCase = true; 2276 find_options.matchCase = true;
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 } 3035 }
3054 3036
3055 void TestRunner::DidLosePointerLockInternal() { 3037 void TestRunner::DidLosePointerLockInternal() {
3056 bool was_locked = pointer_locked_; 3038 bool was_locked = pointer_locked_;
3057 pointer_locked_ = false; 3039 pointer_locked_ = false;
3058 if (was_locked) 3040 if (was_locked)
3059 web_view_->didLosePointerLock(); 3041 web_view_->didLosePointerLock();
3060 } 3042 }
3061 3043
3062 } // namespace content 3044 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/test_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698