15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/extensions/extension_apitest.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_paths.h"
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/test/base/ui_test_utils.h"
81320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/test/result_catcher.h"
9eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "net/test/embedded_test_server/embedded_test_server.h"
107dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "url/gurl.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests that we throw errors when you try using extension APIs that aren't
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// supported in content scripts.
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Timey-outy on mac. http://crbug.com/89116
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define MAYBE_Stubs DISABLED_Stubs
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define MAYBE_Stubs Stubs
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Stubs) {
21eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ASSERT_TRUE(RunExtensionTest("stubs")) << message_;
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Navigate to a simple http:// page, which should get the content script
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // injected and run the rest of the test.
27eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  GURL url(embedded_test_server()->GetURL("/extensions/test_file.html"));
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ui_test_utils::NavigateToURL(browser(), url);
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  extensions::ResultCatcher catcher;
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ASSERT_TRUE(catcher.GetNextResult());
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
33cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Tests that all API features that are available to a platform app actually
35cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// can be used in an app. For example, this test will fail if a developer adds
36cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// an API feature without providing a schema. http://crbug.com/369318
37cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(ExtensionApiTest, StubsApp) {
38116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  ASSERT_TRUE(RunPlatformAppTestWithFlags(
39116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      "stubs_app", static_cast<int>(kFlagIgnoreManifestWarnings)))
40116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      << message_;
41cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)}
42