Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  test_observer_data.js

  Sprache: JAVA
 

"use strict";

var pushNotifier = Cc["@mozilla.org/push/Notifier;1"].getService(
  Ci.nsIPushNotifier
);
var systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();

add_task(async function test_notifyWithData() {
  let textData = '{"hello":"world"}';
  let payload = new TextEncoder().encode(textData);

  let notifyPromise = promiseObserverNotification(
    PushServiceComponent.pushTopic
  );
  pushNotifier.notifyPushWithData(
    "chrome://notify-test",
    systemPrincipal,
    "" /* messageId */,
    payload
  );

  let data = (await notifyPromise).subject.QueryInterface(
    Ci.nsIPushMessage
  ).data;
  deepEqual(
    data.json(),
    {
      hello: "world",
    },
    "Should extract JSON values"
  );
  deepEqual(
    data.binary(),
    Array.from(payload),
    "Should extract raw binary data"
  );
  equal(data.text(), textData, "Should extract text data");
});

add_task(async function test_empty_notifyWithData() {
  let notifyPromise = promiseObserverNotification(
    PushServiceComponent.pushTopic
  );
  pushNotifier.notifyPushWithData(
    "chrome://notify-test",
    systemPrincipal,
    "" /* messageId */,
    []
  );

  let data = (await notifyPromise).subject.QueryInterface(
    Ci.nsIPushMessage
  ).data;
  throws(
    _ => data.json(),
    /InvalidStateError/,
    "Should throw an error when parsing an empty string as JSON"
  );
  strictEqual(data.text(), """Should return an empty string");
  deepEqual(data.binary(), [], "Should return an empty array");
});

Messung V0.5 in Prozent
C=95 H=79 G=87

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002