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

Unified Diff: content/shell/renderer/test_runner/test_runner.cc

Issue 1056913002: Add testRunner.insertStyleSheet for testing style sheet injection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/renderer/test_runner/test_runner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/renderer/test_runner/test_runner.cc
diff --git a/content/shell/renderer/test_runner/test_runner.cc b/content/shell/renderer/test_runner/test_runner.cc
index d56795220cd3c76edf3ade0975ceed119dc5aeab..9f6fceab942753885b858be5359b868ea84577be 100644
--- a/content/shell/renderer/test_runner/test_runner.cc
+++ b/content/shell/renderer/test_runner/test_runner.cc
@@ -40,6 +40,7 @@
#include "third_party/WebKit/public/web/WebGraphicsContext.h"
#include "third_party/WebKit/public/web/WebInputElement.h"
#include "third_party/WebKit/public/web/WebKit.h"
+#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebMIDIClientMock.h"
#include "third_party/WebKit/public/web/WebPageOverlay.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
@@ -187,6 +188,7 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
bool HasCustomPageSizeStyle(int page_index);
void ForceRedSelectionColors();
void InjectStyleSheet(const std::string& source_code, bool all_frames);
+ void InsertStyleSheet(const std::string& source_code);
bool FindString(const std::string& search_text,
const std::vector<std::string>& options_array);
std::string SelectionAsMarkup();
@@ -394,6 +396,7 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
.SetMethod("forceRedSelectionColors",
&TestRunnerBindings::ForceRedSelectionColors)
.SetMethod("injectStyleSheet", &TestRunnerBindings::InjectStyleSheet)
+ .SetMethod("insertStyleSheet", &TestRunnerBindings::InsertStyleSheet)
.SetMethod("findString", &TestRunnerBindings::FindString)
.SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup)
.SetMethod("setTextSubpixelPositioning",
@@ -800,6 +803,11 @@ void TestRunnerBindings::InjectStyleSheet(const std::string& source_code,
runner_->InjectStyleSheet(source_code, all_frames);
}
+void TestRunnerBindings::InsertStyleSheet(const std::string& source_code) {
+ if (runner_)
+ runner_->InsertStyleSheet(source_code);
+}
+
bool TestRunnerBindings::FindString(
const std::string& search_text,
const std::vector<std::string>& options_array) {
@@ -2274,6 +2282,11 @@ void TestRunner::InjectStyleSheet(const std::string& source_code,
: WebView::InjectStyleInTopFrameOnly);
}
+void TestRunner::InsertStyleSheet(const std::string& source_code) {
+ WebLocalFrame::frameForCurrentContext()->document().insertStyleSheet(
+ WebString::fromUTF8(source_code));
+}
+
bool TestRunner::FindString(const std::string& search_text,
const std::vector<std::string>& options_array) {
WebFindOptions find_options;
« 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