author tbirdbld
Sat, 23 Apr 2016 03:05:08 -0700
changeset 22256 23315287d83f0de90d1d8f149b78a4a027b1466d
parent 21479 7d547c917da352ea41bb34b2d4137b5e66a22458
permissions -rw-r--r--
No bug, Automated blocklist update from host bld-linux64-spot-361 - a=blocklist-update

<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at -->

<bindings id="debugLogPanelBindings"

  <binding id="debugLogPanel">
      <stylesheet src="chrome://instantbird/skin/debugLogPanel.css"/>

    <content flex="1">
      <xul:vbox flex="1">
        <xul:toolbar class="debugLogTab-toolbar">
          <xul:menulist class="accountList" anonid="accountList" flex="1"
          <xul:toolbarbutton class="debugLogTab-button" anonid="refreshButton"
          <xul:toolbarbutton class="debugLogTab-button" anonid="copyButton"
        <xul:browser anonid="debugLogBrowser" disablehistory="true" type="content"
                     flex="1" src="chrome://instantbird/content/debugLog.html"/>
        <xul:findbar anonid="findbar"/>

      <property name="browser" readonly="true">
          return document.getAnonymousElementByAttribute(this, "anonid", "debugLogBrowser");

      <property name="findbar" readonly="true">
          return document.getAnonymousElementByAttribute(this, "anonid", "findbar");

      <property name="accountList" readonly="true">
          return document.getAnonymousElementByAttribute(this, "anonid", "accountList");

      <!-- Only show the debug log if the account list is already populated. This
           is useful, for example, if we are importing into a new window and only
           need to repopulate the account list without re-displaying the log. -->
      <method name="onAccountSelect">
          if (this._accountListInited)

      <!-- This method populates the list of accounts and ensures the specified
           account is selected. Since the _inited flag is set here before returning,
           no debug log will be shown. -->
      <method name="initAccountList">
        <parameter name="aAccountId"/>
          if (!("Services" in window))
          let accounts = Services.accounts.getAccounts();
          while (accounts.hasMoreElements()) {
            let acc = accounts.getNext();
            var proto = acc.protocol;
            var item = this.accountList.appendItem(,,;
            item.setAttribute("image", proto.iconBaseURI + "icon.png");
            item.setAttribute("class", "menuitem-iconic");
            let accId =;
            item.accountId = accId;
            if (accId == aAccountId)
              this.accountList.selectedItem = item;
          this._accountListInited = true;
          this.findbar.browser = this.browser;

      <method name="copyDebugLog">

      <method name="showDebugLog">
          let accId = this.accountList.selectedItem.accountId;
          let account = Services.accounts.getAccountById(accId);
"label", "Debug log for " +;
          let doc = this.browser.contentDocument;
          let table = doc.createElement("table");
 = "width: 100%";
          // Clear out any existing content before appending the table.
          doc.body.innerHTML = "";
          for (let dbgMsg of account.getDebugMessages()) {
            let m = dbgMsg.message;
            const dateServ = Cc[";1"]
            let time = new Date(m.timeStamp);
            time = dateServ.FormatDateTime("", dateServ.dateFormatShort,
                                           time.getFullYear(), time.getMonth() + 1,
                                           time.getDate(), time.getHours(),
                                           time.getMinutes(), time.getSeconds());
            let level = dbgMsg.logLevel;
            let rowClass = "default";
            let formattedMsg;
            if (!level)
              formattedMsg = "(" + m.errorMessage + ")";
            else {
              if (level == dbgMsg.LEVEL_ERROR) {
                level = "ERROR";
                rowClass = "error";
              else if (level == dbgMsg.LEVEL_WARNING) {
                level = "WARN.";
                rowClass = "warn";
              else if (level == dbgMsg.LEVEL_LOG) {
                level = "LOG  ";
                rowClass = "log";
              else {
                level = "DEBUG";
                rowClass = "debug";
              formattedMsg = level + " (@ " + m.sourceLine +
                " " + m.sourceName + ":" + m.lineNumber + ")\n" +
            let tr = doc.createElement("tr");
            tr.className = rowClass;
            let timeCell = doc.createElement("td");
            timeCell.className = "time";
            let msgCell = doc.createElement("td");
            msgCell.className = "msg";
            // A trailing space after the timestamp a the trailing line break
            // after the debug message are necessary to ensure correct formatting
            // when text is selected/copied.
            timeCell.textContent = "[" + time + "] ";
            // Due to bug 116083, newlines that are forcibly displayed using
            // `white-space: pre;` are not preserved when the text is copied.
            // To work around this, we split the message into lines, and append a
            // text node and a <br/> element for each line.
            // The <br/> elements are not perfect substitutes for the newline
            // characters, however. copyDebugLog uses document.body.textContent
            // to get the entire contents of the debug log, and textContent does
            // not account for <br/> elements.
            // So, we keep the newline characters (which are hidden because white-
            // space is collapsed by default in html), as well as the <br/> elements
            // to ensure text is correctly displayed as well as copied.
            let lines = formattedMsg.split("\n");
            for (let line of lines) {
              let textNode = doc.createTextNode(line + "\n");
              let brNode = doc.createElement("br");
          // Ensure the scroll position is reset.
          doc.body.scrollTop = 0;
          doc.body.scrollLeft = 0;

      <method name="finishImport">
        <parameter name="aDebugLogPanel"/>