LCOV - code coverage report
Current view: top level - dom/bindings/test - TestFunctions.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 31 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "mozilla/dom/TestFunctions.h"
       8             : #include "mozilla/dom/TestFunctionsBinding.h"
       9             : #include "nsStringBuffer.h"
      10             : 
      11             : namespace mozilla {
      12             : namespace dom {
      13             : 
      14             : /* static */ TestFunctions*
      15           0 : TestFunctions::Constructor(GlobalObject& aGlobal, ErrorResult& aRv)
      16             : {
      17           0 :   return new TestFunctions;
      18             : }
      19             : 
      20             : /* static */ void
      21           0 : TestFunctions::ThrowUncatchableException(GlobalObject& aGlobal,
      22             :                                          ErrorResult& aRv)
      23             : {
      24           0 :   aRv.ThrowUncatchableException();
      25           0 : }
      26             : 
      27             : /* static */ Promise*
      28           0 : TestFunctions::PassThroughPromise(GlobalObject& aGlobal, Promise& aPromise)
      29             : {
      30           0 :   return &aPromise;
      31             : }
      32             : 
      33             : /* static */ already_AddRefed<Promise>
      34           0 : TestFunctions::PassThroughCallbackPromise(GlobalObject& aGlobal,
      35             :                                           PromiseReturner& aCallback,
      36             :                                           ErrorResult& aRv)
      37             : {
      38           0 :   return aCallback.Call(aRv);
      39             : }
      40             : 
      41             : void
      42           0 : TestFunctions::SetStringData(const nsAString& aString)
      43             : {
      44           0 :   mStringData = aString;
      45           0 : }
      46             : 
      47             : void
      48           0 : TestFunctions::GetStringDataAsAString(nsAString& aString)
      49             : {
      50           0 :   aString = mStringData;
      51           0 : }
      52             : 
      53             : void
      54           0 : TestFunctions::GetStringDataAsAString(uint32_t aLength, nsAString& aString)
      55             : {
      56           0 :   MOZ_RELEASE_ASSERT(aLength <= mStringData.Length(),
      57             :                      "Bogus test passing in a too-big length");
      58           0 :   aString.Assign(mStringData.BeginReading(), aLength);
      59           0 : }
      60             : 
      61             : void
      62           0 : TestFunctions::GetStringDataAsDOMString(const Optional<uint32_t>& aLength,
      63             :                                         DOMString& aString)
      64             : {
      65             :   uint32_t length;
      66           0 :   if (aLength.WasPassed()) {
      67           0 :     length = aLength.Value();
      68           0 :     MOZ_RELEASE_ASSERT(length <= mStringData.Length(),
      69             :                        "Bogus test passing in a too-big length");
      70             :   } else {
      71           0 :     length = mStringData.Length();
      72             :   }
      73             : 
      74           0 :   nsStringBuffer* buf = nsStringBuffer::FromString(mStringData);
      75           0 :   if (buf) {
      76           0 :     aString.SetStringBuffer(buf, length);
      77           0 :     return;
      78             :   }
      79             : 
      80             :   // We better have an empty mStringData; otherwise why did we not have a string
      81             :   // buffer?
      82           0 :   MOZ_RELEASE_ASSERT(length == 0, "Why no stringbuffer?");
      83             :   // No need to do anything here; aString is already empty.
      84             : }
      85             : 
      86             : bool
      87           0 : TestFunctions::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
      88             :                           JS::MutableHandle<JSObject*> aWrapper)
      89             : {
      90           0 :   return TestFunctionsBinding::Wrap(aCx, this, aGivenProto, aWrapper);
      91             : }
      92             : 
      93             : }
      94             : }

Generated by: LCOV version 1.13