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

Side by Side Diff: chrome/browser/extensions/service_worker_apitest.cc

Issue 1211243010: [Service Worker Registration] Registered extension scheme to allow service workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added dev test Created 5 years, 5 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extension_apitest.h"
6 #include "extensions/test/extension_test_message_listener.h"
7
8 namespace extensions {
9
10 class ServiceWorkerTest : public ExtensionApiTest {
11 public:
12 // Set the channel to "trunk" since service workers are restricted to trunk.
13 ServiceWorkerTest()
14 : current_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {}
15
16 ~ServiceWorkerTest() override {}
17
18 private:
19 extensions::ScopedCurrentChannel current_channel_;
20 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerTest);
21 };
22
23 // This should fail because there are changes to be made to
24 // successfully register a service worker.
25 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, RegisterServiceWorkerTrunk) {
26 ExtensionTestMessageListener listener(false);
27 ASSERT_FALSE(RunExtensionTest("service_worker/register")) << message_;
28 ASSERT_TRUE(listener.WaitUntilSatisfied());
29 if (listener.message() != "success") {
Devlin 2015/07/13 19:32:24 Instead of this, we should just assert that the er
annekao 2015/07/13 21:15:59 Done.
30 ASSERT_EQ(
31 "SecurityError: Failed to register a ServiceWorker: No URL is "
32 "associated with the caller's document.",
33 listener.message());
34 }
35 }
36
37 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, RegisterServiceWorkerDev) {
Devlin 2015/07/13 19:32:24 Maybe rename this to "CannotRegisterServiceWorkers
annekao 2015/07/13 21:15:59 Done.
38 extensions::ScopedCurrentChannel current_channel_override(
Devlin 2015/07/13 19:32:24 nit: this is already in the extensions namespace,
annekao 2015/07/13 21:15:59 Done.
39 chrome::VersionInfo::CHANNEL_DEV);
40 ExtensionTestMessageListener listener(false);
41 ASSERT_FALSE(RunExtensionTest("service_worker/register")) << message_;
42 ASSERT_TRUE(listener.WaitUntilSatisfied());
43 if (listener.message() != "success") {
44 ASSERT_EQ(
45 "SecurityError: Failed to register a ServiceWorker: The URL "
46 "protocol of the current origin ('chrome-extension://" +
47 GetSingleLoadedExtension()->id() + "') is not supported.",
48 listener.message());
49 }
50 }
51
52 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | chrome/test/data/extensions/api_test/service_worker/register/test.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698