title: Office.initialize is not called randomly in dialog
body: <p>I am using <code>Office.context.ui.displayDialogAsync</code> to open a dialog. After authentication and a couple of redirects, the dialog eventually redirects to a simple page that is responsible for calling back the parent. </p>
  
  <p>Here is the code of page:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;title&gt;Loading...&lt;/title&gt;
  
      &lt;script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          document.write(1);
          Office.initialize = function () {
              document.write(2);
              Office.context.ui.messageParent('Hello World!');
              document.write(3);
          };
          document.write(5);
  
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      Loading...
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Sometimes, <code>Office.initialize</code> is called and all 5 <code>document.write</code> statements are printed however, sometimes, randomly only 1 &amp; 5 are printed. Which means that <code>Office.initialize</code> was not called.</p>
  
  <p>Is it a bug in office.js or am I doing something wrong?</p>
  
  <ul>
  <li>OS: MacOS High Sierra (10.13.4)</li>
  <li>Outlook version: 16.11 (180311)</li>
  </ul>
  
  <p><strong>Update:</strong> I tried the same code on Office Online. It works fine on Firefox &amp; Chrome. However, on Safari, the behavior is the same as Outlook Desktop. As the Outlook Desktop on MacOS uses Safari, can this be something related to Office.js compatibility with Safari?</p>
  
  <p><strong>Update2:</strong> I have used VanillaJS instead and it works flawlessly on:</p>
  
  <ul>
  <li>Outlook Desktop (MacOS)</li>
  <li>Outlook Web on Firefox</li>
  <li>Outlook Web on Chrome</li>
  <li>Outlook Web on Safari</li>
  </ul>
  
  <p>Here is the code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;title&gt;Loading...&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
          window.onload = function() {
              window.opener.postMessage("Hello World!"), window.location.origin);
          };
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      Loading...
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>In parent window, I use:</p>
  
  <pre><code>window.addEventListener("message", function(event){
      if(event.origin !== window.origin) return;
      console.log(event.data);
  }, false);
  </code></pre>