tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TestReportBody.cpp (1211B)


      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/TestReportBody.h"
      8 
      9 #include "mozilla/JSONWriter.h"
     10 #include "mozilla/dom/ReportingBinding.h"
     11 
     12 namespace mozilla::dom {
     13 
     14 TestReportBody::TestReportBody(nsIGlobalObject* aGlobal,
     15                               const nsString& aMessage)
     16    : ReportBody(aGlobal), mMessage(aMessage) {}
     17 
     18 JSObject* TestReportBody::WrapObject(JSContext* aCx,
     19                                     JS::Handle<JSObject*> aGivenProto) {
     20  return TestReportBody_Binding::Wrap(aCx, this, aGivenProto);
     21 }
     22 
     23 TestReportBody::~TestReportBody() = default;
     24 
     25 void TestReportBody::GetMessage(nsAString& aMessage) const {
     26  aMessage = mMessage;
     27 }
     28 
     29 void TestReportBody::ToJSON(JSONWriter& aJSONWriter) const {
     30  if (mMessage.IsEmpty()) {
     31    aJSONWriter.NullProperty("message");
     32  } else {
     33    aJSONWriter.StringProperty("message", NS_ConvertUTF16toUTF8(mMessage));
     34  }
     35 }
     36 }  // namespace mozilla::dom