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

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

Issue 584553002: Extend the TestRunner so that the manifest-src CSP directive can be tested from layout tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate feedback Created 6 years, 2 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 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/shell/common/test_runner/test_preferences.h" 11 #include "content/shell/common/test_runner/test_preferences.h"
11 #include "content/shell/renderer/binding_helpers.h" 12 #include "content/shell/renderer/binding_helpers.h"
12 #include "content/shell/renderer/test_runner/WebTestDelegate.h" 13 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
13 #include "content/shell/renderer/test_runner/mock_credential_manager_client.h" 14 #include "content/shell/renderer/test_runner/mock_credential_manager_client.h"
14 #include "content/shell/renderer/test_runner/mock_web_push_client.h" 15 #include "content/shell/renderer/test_runner/mock_web_push_client.h"
15 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" 16 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h"
16 #include "content/shell/renderer/test_runner/notification_presenter.h" 17 #include "content/shell/renderer/test_runner/notification_presenter.h"
17 #include "content/shell/renderer/test_runner/test_interfaces.h" 18 #include "content/shell/renderer/test_runner/test_interfaces.h"
18 #include "content/shell/renderer/test_runner/web_permissions.h" 19 #include "content/shell/renderer/test_runner/web_permissions.h"
19 #include "content/shell/renderer/test_runner/web_test_proxy.h" 20 #include "content/shell/renderer/test_runner/web_test_proxy.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 const std::string& message); 280 const std::string& message);
280 bool WasMockSpeechRecognitionAborted(); 281 bool WasMockSpeechRecognitionAborted();
281 void AddMockCredentialManagerResponse(const std::string& id, 282 void AddMockCredentialManagerResponse(const std::string& id,
282 const std::string& name, 283 const std::string& name,
283 const std::string& avatar, 284 const std::string& avatar,
284 const std::string& password); 285 const std::string& password);
285 void AddWebPageOverlay(); 286 void AddWebPageOverlay();
286 void RemoveWebPageOverlay(); 287 void RemoveWebPageOverlay();
287 void DisplayAsync(); 288 void DisplayAsync();
288 void DisplayAsyncThen(v8::Handle<v8::Function> callback); 289 void DisplayAsyncThen(v8::Handle<v8::Function> callback);
290 void GetManifestThen(v8::Handle<v8::Function> callback);
289 void CapturePixelsAsyncThen(v8::Handle<v8::Function> callback); 291 void CapturePixelsAsyncThen(v8::Handle<v8::Function> callback);
290 void CopyImageAtAndCapturePixelsAsyncThen(int x, 292 void CopyImageAtAndCapturePixelsAsyncThen(int x,
291 int y, 293 int y,
292 v8::Handle<v8::Function> callback); 294 v8::Handle<v8::Function> callback);
293 void SetCustomTextOutput(std::string output); 295 void SetCustomTextOutput(std::string output);
294 void SetViewSourceForFrame(const std::string& name, bool enabled); 296 void SetViewSourceForFrame(const std::string& name, bool enabled);
295 void SetMockPushClientSuccess(const std::string& endpoint, 297 void SetMockPushClientSuccess(const std::string& endpoint,
296 const std::string& registration_id); 298 const std::string& registration_id);
297 void SetMockPushClientError(const std::string& message); 299 void SetMockPushClientError(const std::string& message);
298 300
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 &TestRunnerBindings::SetMockSpeechRecognitionError) 521 &TestRunnerBindings::SetMockSpeechRecognitionError)
520 .SetMethod("wasMockSpeechRecognitionAborted", 522 .SetMethod("wasMockSpeechRecognitionAborted",
521 &TestRunnerBindings::WasMockSpeechRecognitionAborted) 523 &TestRunnerBindings::WasMockSpeechRecognitionAborted)
522 .SetMethod("addMockCredentialManagerResponse", 524 .SetMethod("addMockCredentialManagerResponse",
523 &TestRunnerBindings::AddMockCredentialManagerResponse) 525 &TestRunnerBindings::AddMockCredentialManagerResponse)
524 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) 526 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay)
525 .SetMethod("removeWebPageOverlay", 527 .SetMethod("removeWebPageOverlay",
526 &TestRunnerBindings::RemoveWebPageOverlay) 528 &TestRunnerBindings::RemoveWebPageOverlay)
527 .SetMethod("displayAsync", &TestRunnerBindings::DisplayAsync) 529 .SetMethod("displayAsync", &TestRunnerBindings::DisplayAsync)
528 .SetMethod("displayAsyncThen", &TestRunnerBindings::DisplayAsyncThen) 530 .SetMethod("displayAsyncThen", &TestRunnerBindings::DisplayAsyncThen)
531 .SetMethod("getManifestThen", &TestRunnerBindings::GetManifestThen)
529 .SetMethod("capturePixelsAsyncThen", 532 .SetMethod("capturePixelsAsyncThen",
530 &TestRunnerBindings::CapturePixelsAsyncThen) 533 &TestRunnerBindings::CapturePixelsAsyncThen)
531 .SetMethod("copyImageAtAndCapturePixelsAsyncThen", 534 .SetMethod("copyImageAtAndCapturePixelsAsyncThen",
532 &TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen) 535 &TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen)
533 .SetMethod("setCustomTextOutput", 536 .SetMethod("setCustomTextOutput",
534 &TestRunnerBindings::SetCustomTextOutput) 537 &TestRunnerBindings::SetCustomTextOutput)
535 .SetMethod("setViewSourceForFrame", 538 .SetMethod("setViewSourceForFrame",
536 &TestRunnerBindings::SetViewSourceForFrame) 539 &TestRunnerBindings::SetViewSourceForFrame)
537 .SetMethod("setMockPushClientSuccess", 540 .SetMethod("setMockPushClientSuccess",
538 &TestRunnerBindings::SetMockPushClientSuccess) 541 &TestRunnerBindings::SetMockPushClientSuccess)
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 void TestRunnerBindings::DisplayAsync() { 1354 void TestRunnerBindings::DisplayAsync() {
1352 if (runner_) 1355 if (runner_)
1353 runner_->DisplayAsync(); 1356 runner_->DisplayAsync();
1354 } 1357 }
1355 1358
1356 void TestRunnerBindings::DisplayAsyncThen(v8::Handle<v8::Function> callback) { 1359 void TestRunnerBindings::DisplayAsyncThen(v8::Handle<v8::Function> callback) {
1357 if (runner_) 1360 if (runner_)
1358 runner_->DisplayAsyncThen(callback); 1361 runner_->DisplayAsyncThen(callback);
1359 } 1362 }
1360 1363
1364 void TestRunnerBindings::GetManifestThen(v8::Handle<v8::Function> callback) {
1365 if (runner_)
1366 runner_->GetManifestThen(callback);
1367 }
1368
1361 void TestRunnerBindings::CapturePixelsAsyncThen( 1369 void TestRunnerBindings::CapturePixelsAsyncThen(
1362 v8::Handle<v8::Function> callback) { 1370 v8::Handle<v8::Function> callback) {
1363 if (runner_) 1371 if (runner_)
1364 runner_->CapturePixelsAsyncThen(callback); 1372 runner_->CapturePixelsAsyncThen(callback);
1365 } 1373 }
1366 1374
1367 void TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen( 1375 void TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen(
1368 int x, int y, v8::Handle<v8::Function> callback) { 1376 int x, int y, v8::Handle<v8::Function> callback) {
1369 if (runner_) 1377 if (runner_)
1370 runner_->CopyImageAtAndCapturePixelsAsyncThen(x, y, callback); 1378 runner_->CopyImageAtAndCapturePixelsAsyncThen(x, y, callback);
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2797 } 2805 }
2798 2806
2799 void TestRunner::DisplayAsyncThen(v8::Handle<v8::Function> callback) { 2807 void TestRunner::DisplayAsyncThen(v8::Handle<v8::Function> callback) {
2800 scoped_ptr<InvokeCallbackTask> task( 2808 scoped_ptr<InvokeCallbackTask> task(
2801 new InvokeCallbackTask(this, callback)); 2809 new InvokeCallbackTask(this, callback));
2802 proxy_->DisplayAsyncThen(base::Bind(&TestRunner::InvokeCallback, 2810 proxy_->DisplayAsyncThen(base::Bind(&TestRunner::InvokeCallback,
2803 base::Unretained(this), 2811 base::Unretained(this),
2804 base::Passed(&task))); 2812 base::Passed(&task)));
2805 } 2813 }
2806 2814
2815 void TestRunner::GetManifestThen(v8::Handle<v8::Function> callback) {
2816 scoped_ptr<InvokeCallbackTask> task(
2817 new InvokeCallbackTask(this, callback));
2818
2819 GURL url(web_view_->mainFrame()->document().manifestURL());
Mike West 2014/09/24 15:15:47 Nit: Do you need the temp variable? I'd just put i
2820
2821 FetchManifest(web_view_, url,
2822 base::Bind(&TestRunner::GetManifestCallback,
2823 base::Unretained(this),
2824 base::Passed(&task)));
2825 }
2826
2807 void TestRunner::CapturePixelsAsyncThen(v8::Handle<v8::Function> callback) { 2827 void TestRunner::CapturePixelsAsyncThen(v8::Handle<v8::Function> callback) {
2808 scoped_ptr<InvokeCallbackTask> task( 2828 scoped_ptr<InvokeCallbackTask> task(
2809 new InvokeCallbackTask(this, callback)); 2829 new InvokeCallbackTask(this, callback));
2810 proxy_->CapturePixelsAsync(base::Bind(&TestRunner::CapturePixelsCallback, 2830 proxy_->CapturePixelsAsync(base::Bind(&TestRunner::CapturePixelsCallback,
2811 base::Unretained(this), 2831 base::Unretained(this),
2812 base::Passed(&task))); 2832 base::Passed(&task)));
2813 } 2833 }
2814 2834
2815 void TestRunner::CopyImageAtAndCapturePixelsAsyncThen( 2835 void TestRunner::CopyImageAtAndCapturePixelsAsyncThen(
2816 int x, int y, v8::Handle<v8::Function> callback) { 2836 int x, int y, v8::Handle<v8::Function> callback) {
2817 scoped_ptr<InvokeCallbackTask> task( 2837 scoped_ptr<InvokeCallbackTask> task(
2818 new InvokeCallbackTask(this, callback)); 2838 new InvokeCallbackTask(this, callback));
2819 proxy_->CopyImageAtAndCapturePixels( 2839 proxy_->CopyImageAtAndCapturePixels(
2820 x, y, base::Bind(&TestRunner::CapturePixelsCallback, 2840 x, y, base::Bind(&TestRunner::CapturePixelsCallback,
2821 base::Unretained(this), 2841 base::Unretained(this),
2822 base::Passed(&task))); 2842 base::Passed(&task)));
2823 } 2843 }
2824 2844
2845 void TestRunner::GetManifestCallback(scoped_ptr<InvokeCallbackTask> task,
2846 const blink::WebURLResponse& response,
2847 const std::string& data) {
2848 InvokeCallback(task.Pass());
2849 }
2850
2825 void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task, 2851 void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task,
2826 const SkBitmap& snapshot) { 2852 const SkBitmap& snapshot) {
2827 v8::Isolate* isolate = blink::mainThreadIsolate(); 2853 v8::Isolate* isolate = blink::mainThreadIsolate();
2828 v8::HandleScope handle_scope(isolate); 2854 v8::HandleScope handle_scope(isolate);
2829 2855
2830 v8::Handle<v8::Context> context = 2856 v8::Handle<v8::Context> context =
2831 web_view_->mainFrame()->mainWorldScriptContext(); 2857 web_view_->mainFrame()->mainWorldScriptContext();
2832 if (context.IsEmpty()) 2858 if (context.IsEmpty())
2833 return; 2859 return;
2834 2860
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2922 } 2948 }
2923 2949
2924 void TestRunner::DidLosePointerLockInternal() { 2950 void TestRunner::DidLosePointerLockInternal() {
2925 bool was_locked = pointer_locked_; 2951 bool was_locked = pointer_locked_;
2926 pointer_locked_ = false; 2952 pointer_locked_ = false;
2927 if (was_locked) 2953 if (was_locked)
2928 web_view_->didLosePointerLock(); 2954 web_view_->didLosePointerLock();
2929 } 2955 }
2930 2956
2931 } // namespace content 2957 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698