| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "core/experiments/Experiments.h" | 5 #include "core/experiments/Experiments.h" |
| 6 | 6 |
| 7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
| 8 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
| 9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| 11 #include "core/html/HTMLDocument.h" | 11 #include "core/html/HTMLDocument.h" |
| 12 #include "core/html/HTMLHeadElement.h" | 12 #include "core/html/HTMLHeadElement.h" |
| 13 #include "core/html/HTMLMetaElement.h" | 13 #include "core/html/HTMLMetaElement.h" |
| 14 #include "core/testing/DummyPageHolder.h" | 14 #include "core/testing/DummyPageHolder.h" |
| 15 #include "platform/weborigin/KURL.h" | 15 #include "platform/weborigin/KURL.h" |
| 16 #include "platform/weborigin/SecurityOrigin.h" | 16 #include "platform/weborigin/SecurityOrigin.h" |
| 17 #include "public/platform/WebApiKeyValidator.h" | 17 #include "public/platform/WebApiKeyValidator.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const char* kNonExistingAPIName = "This API does not exist"; | 23 const char kNonExistingAPIName[] = "This API does not exist"; |
| 24 const char* kFrobulateAPIName = "Frobulate"; | 24 const char kFrobulateAPIName[] = "Frobulate"; |
| 25 const char* kFrobulateEnabledOrigin = "https://www.example.com"; | 25 const char kFrobulateEnabledOrigin[] = "https://www.example.com"; |
| 26 const char* kFrobulateEnabledOriginUnsecure = "http://www.example.com"; | 26 const char kFrobulateEnabledOriginUnsecure[] = "http://www.example.com"; |
| 27 | 27 |
| 28 // API Key which will appear valid | 28 // API Key that will appear valid. |
| 29 const char* kGoodAPIKey = "AnySignatureWillDo|https://www.example.com|Frobulate|
2000000000"; | 29 const char kGoodAPIKey[] = "AnySignatureWillDo|https://www.example.com|Frobulate
|2000000000"; |
| 30 | 30 |
| 31 class MockApiKeyValidator : public WebApiKeyValidator { | 31 class MockApiKeyValidator : public WebApiKeyValidator { |
| 32 public: | 32 public: |
| 33 MockApiKeyValidator() | 33 MockApiKeyValidator() |
| 34 : m_response(false) | 34 : m_response(false) |
| 35 , m_callCount(0) | 35 , m_callCount(0) |
| 36 { | 36 { |
| 37 } | 37 } |
| 38 ~MockApiKeyValidator() override {} | 38 ~MockApiKeyValidator() override {} |
| 39 | 39 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 225 |
| 226 TEST_F(ExperimentsTest, DisabledException) | 226 TEST_F(ExperimentsTest, DisabledException) |
| 227 { | 227 { |
| 228 DOMException* disabledException = Experiments::createApiDisabledException(kN
onExistingAPIName); | 228 DOMException* disabledException = Experiments::createApiDisabledException(kN
onExistingAPIName); |
| 229 ASSERT_TRUE(disabledException) << "An exception should have been created"; | 229 ASSERT_TRUE(disabledException) << "An exception should have been created"; |
| 230 EXPECT_EQ(DOMException::getErrorName(NotSupportedError), disabledException->
name()); | 230 EXPECT_EQ(DOMException::getErrorName(NotSupportedError), disabledException->
name()); |
| 231 EXPECT_TRUE(disabledException->message().contains(kNonExistingAPIName)) << "
Message should contain the API name, was: " << disabledException->message(); | 231 EXPECT_TRUE(disabledException->message().contains(kNonExistingAPIName)) << "
Message should contain the API name, was: " << disabledException->message(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 } // namespace blink | 234 } // namespace blink |
| OLD | NEW |