Commit debfb4ec authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

CredentialsContainerTest: Rename methods to avoid naming conflicts

GCC is stricter than clang when it comes to class members' names and how
they can change the meaning of a previously existing symbol with the same
name:

       Document* Document() { return &dummy_context_.GetDocument(); }
                                                                ^
    In file included from ../../third_party/WebKit/Source/modules/credentialmanager/CredentialsContainerTest.cpp:12:0:
    ../../third_party/WebKit/Source/core/dom/Document.h:248:19: error: changes meaning of ‘Document’ from ‘class blink::Document’ [-fpermissive]
     class CORE_EXPORT Document : public ContainerNode,
                   ^~~~~~~~
    ../../third_party/WebKit/Source/modules/credentialmanager/CredentialsContainerTest.cpp:114:72: error: declaration of ‘blink::ScriptState* blink::{anonymous}::CredentialManagerTestingContext::ScriptState()’ [-fpermissive]
       ScriptState* ScriptState() { return dummy_context_.GetScriptState(); }
                                                                        ^
    In file included from ../../third_party/WebKit/Source/bindings/core/v8/ScriptValue.h:37:0,
                     from ../../third_party/WebKit/Source/bindings/core/v8/ScriptFunction.h:34,
                     from ../../third_party/WebKit/Source/bindings/core/v8/ScriptPromise.h:35,
                     from ../../third_party/WebKit/Source/bindings/core/v8/ExceptionState.h:34,
                     from ../../third_party/WebKit/Source/bindings/core/v8/V8BindingForTesting.h:8,
                     from ../../third_party/WebKit/Source/modules/credentialmanager/CredentialsContainerTest.cpp:10:
    ../../third_party/WebKit/Source/platform/bindings/ScriptState.h:66:23: error: changes meaning of ‘ScriptState’ from ‘class blink::ScriptState’ [-fpermissive]
     class PLATFORM_EXPORT ScriptState : public RefCounted<ScriptState> {
                           ^~~~~~~~~~~

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84709 contains a longer
explanation, but essentially having a |Document()| or |ScriptState()| method
can change the meaning of references to the outside types in the code
depending on where it is declared, which contradicts the C++ standard.

Fix it by renaming the methods to |GetDocument()| and |GetScriptState()|.

Change-Id: I037d009c52a5e44838e90d1b8ea330acf922afaa
Reviewed-on: https://chromium-review.googlesource.com/968515Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/master@{#544041}
parent 8e51cf0c
...@@ -109,9 +109,9 @@ class CredentialManagerTestingContext { ...@@ -109,9 +109,9 @@ class CredentialManagerTestingContext {
WTF::Unretained(mock_credential_manager))); WTF::Unretained(mock_credential_manager)));
} }
Document* Document() { return &dummy_context_.GetDocument(); } Document* GetDocument() { return &dummy_context_.GetDocument(); }
LocalFrame* Frame() { return &dummy_context_.GetFrame(); } LocalFrame* Frame() { return &dummy_context_.GetFrame(); }
ScriptState* ScriptState() { return dummy_context_.GetScriptState(); } ScriptState* GetScriptState() { return dummy_context_.GetScriptState(); }
private: private:
V8TestingScope dummy_context_; V8TestingScope dummy_context_;
...@@ -128,8 +128,8 @@ TEST(CredentialsContainerTest, PendingGetRequest_NoGCCycles) { ...@@ -128,8 +128,8 @@ TEST(CredentialsContainerTest, PendingGetRequest_NoGCCycles) {
{ {
CredentialManagerTestingContext context(&mock_credential_manager); CredentialManagerTestingContext context(&mock_credential_manager);
weak_document = context.Document(); weak_document = context.GetDocument();
CredentialsContainer::Create()->get(context.ScriptState(), CredentialsContainer::Create()->get(context.GetScriptState(),
CredentialRequestOptions()); CredentialRequestOptions());
mock_credential_manager.WaitForCallToGet(); mock_credential_manager.WaitForCallToGet();
} }
...@@ -150,12 +150,12 @@ TEST(CredentialsContainerTest, ...@@ -150,12 +150,12 @@ TEST(CredentialsContainerTest,
MockCredentialManager mock_credential_manager; MockCredentialManager mock_credential_manager;
CredentialManagerTestingContext context(&mock_credential_manager); CredentialManagerTestingContext context(&mock_credential_manager);
auto* proxy = CredentialManagerProxy::From(context.Document()); auto* proxy = CredentialManagerProxy::From(context.GetDocument());
auto promise = CredentialsContainer::Create()->get( auto promise = CredentialsContainer::Create()->get(
context.ScriptState(), CredentialRequestOptions()); context.GetScriptState(), CredentialRequestOptions());
mock_credential_manager.WaitForCallToGet(); mock_credential_manager.WaitForCallToGet();
context.Document()->Shutdown(); context.GetDocument()->Shutdown();
mock_credential_manager.InvokeGetCallback(); mock_credential_manager.InvokeGetCallback();
proxy->FlushCredentialManagerConnectionForTesting(); proxy->FlushCredentialManagerConnectionForTesting();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment