Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/webauthn/AuthenticatorAttestationResponse.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "mozilla/dom/WebAuthenticationBinding.h"
8
#include "mozilla/dom/AuthenticatorAttestationResponse.h"
9
10
namespace mozilla {
11
namespace dom {
12
13
NS_IMPL_CYCLE_COLLECTION_CLASS(AuthenticatorAttestationResponse)
14
0
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(AuthenticatorAttestationResponse,
15
0
                                                AuthenticatorResponse)
16
0
  tmp->mAttestationObjectCachedObj = nullptr;
17
0
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
18
19
0
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(AuthenticatorAttestationResponse,
20
0
                                               AuthenticatorResponse)
21
0
  NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
22
0
  NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mAttestationObjectCachedObj)
23
0
NS_IMPL_CYCLE_COLLECTION_TRACE_END
24
25
0
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(AuthenticatorAttestationResponse,
26
0
                                                  AuthenticatorResponse)
27
0
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
28
29
NS_IMPL_ADDREF_INHERITED(AuthenticatorAttestationResponse, AuthenticatorResponse)
30
NS_IMPL_RELEASE_INHERITED(AuthenticatorAttestationResponse, AuthenticatorResponse)
31
32
0
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AuthenticatorAttestationResponse)
33
0
NS_INTERFACE_MAP_END_INHERITING(AuthenticatorResponse)
34
35
AuthenticatorAttestationResponse::AuthenticatorAttestationResponse(nsPIDOMWindowInner* aParent)
36
  : AuthenticatorResponse(aParent)
37
  , mAttestationObjectCachedObj(nullptr)
38
0
{
39
0
  mozilla::HoldJSObjects(this);
40
0
}
41
42
AuthenticatorAttestationResponse::~AuthenticatorAttestationResponse()
43
0
{
44
0
  mozilla::DropJSObjects(this);
45
0
}
46
47
JSObject*
48
AuthenticatorAttestationResponse::WrapObject(JSContext* aCx,
49
                                             JS::Handle<JSObject*> aGivenProto)
50
0
{
51
0
  return AuthenticatorAttestationResponse_Binding::Wrap(aCx, this, aGivenProto);
52
0
}
53
54
void
55
AuthenticatorAttestationResponse::GetAttestationObject(JSContext* aCx,
56
                                                       JS::MutableHandle<JSObject*> aRetVal)
57
0
{
58
0
  if (!mAttestationObjectCachedObj) {
59
0
    mAttestationObjectCachedObj = mAttestationObject.ToArrayBuffer(aCx);
60
0
  }
61
0
  aRetVal.set(mAttestationObjectCachedObj);
62
0
}
63
64
nsresult
65
AuthenticatorAttestationResponse::SetAttestationObject(CryptoBuffer& aBuffer)
66
0
{
67
0
  if (NS_WARN_IF(!mAttestationObject.Assign(aBuffer))) {
68
0
    return NS_ERROR_OUT_OF_MEMORY;
69
0
  }
70
0
  return NS_OK;
71
0
}
72
73
} // namespace dom
74
} // namespace mozilla