Send response only when iframe is loaded on all browsers (see "iframe-loaded" event on io section)
325451
function(id, url, entry, response) {
      return function wait() {
        try {
          (urlData[id].counter > 0) ? setTimeout(wait, WAIT_TIMEOUT) : response.json(entry);
        } catch (error) {
          console.log("   error -".red, "Error openning".yellow, url, error);
        }
      };
    }
212834
def responds_to_parent(&block)
      yield

      if performed?
        # Either pull out a redirect or the request body
        script =  if response.headers['Location']
                    #TODO: erase_redirect_results is missing in rails 3.0
                    "document.location.href = '#{self.class.helpers.escape_javascript location.to_s}'"
                  else
                    response.body || ''
                  end

        # Eval in parent scope and replace document location of this frame
        # so back button doesn't replay action on targeted forms
        # loc = document.location to be set after parent is updated for IE
        # with(window.parent) - pull in variables from parent window
        # setTimeout - scope the execution in the windows parent for safari
        # window.eval - legal eval for Opera
        script = "<html><body><script type='text/javascript' charset='utf-8'>
          var loc = document.location;
          with(window.parent) { setTimeout(function() { window.eval('#{self.class.helpers.escape_javascript script}'); window.loc && loc.replace('about:blank'); }, 1) }
        </script></body></html>"

        # We're returning HTML instead of JS or XML now
        response.headers['Content-Type'] = 'text/html; charset=UTF-8'

        # Clear out the previous render to prevent double render and then render
        if respond_to?(:erase_results, true)
          erase_results
        else
          instance_variable_set(:@_response_body, nil)
        end

        render :text => script
      end
    end
1026047
function onYouTubePlayerAPIReady() {
  // Loop through each iframe video on the page
  jQuery( "iframe.copy-video__video").each(function (index) {

    // Create IDs dynamically
    var iframeID = "js-copy-video-" + index;
    var buttonID = "js-copy-video-" + index + "__button";

    // Set IDs
    jQuery(this).attr('id', iframeID);
    jQuery(this).next('button.copy-video__button').attr('id', buttonID);

    // Associate video player with button via index
    players[buttonID] = { player: null, }

    // Set-up a player object for each video
    players[buttonID].player =  new YT.Player(iframeID, {
      events: { 'onReady': onPlayerReady }
    });
  });
}
603778
function completed(event) {
            var iframeDoc;

            // IE < 10 (also 11?) gives 'Permission Denied' if trying to access
            // the iframeDoc from the context of the function above.
            // We need to re-get it from the DOM.
            iframeDoc = J.getIFrameDocument(iframe);

            // readyState === "complete" works also in oldIE.
            if (event.type === 'load' ||
                iframeDoc.readyState === 'complete') {

                // Detaching the function to avoid double execution.
                iframe.detachEvent('onreadystatechange', completed );
                iframeWin.detachEvent('onload', completed );

                if (cb) {
                    // Some browsers fire onLoad too early.
                    // A small timeout is enough.
                    setTimeout(function() { cb(); }, 120);
                }
            }
        }
1003175
def _BuildResponse(self,
                     status,
                     rendered_data,
                     method_name=None,
                     headers=None,
                     content_length=None,
                     token=None,
                     no_audit_log=False):
    """"""

    # To avoid IE content sniffing problems, escape the tags. Otherwise somebody
    # may send a link with malicious payload that will be opened in IE (which
    # does content sniffing and doesn't respect Content-Disposition header) and
    # IE will treat the document as html and executre arbitrary JS that was
    # passed with the payload.
    str_data = json.Dump(
        rendered_data, encoder=JSONEncoderWithRDFPrimitivesSupport)
    # XSSI protection and tags escaping
    rendered_data = ")]}'\n" + str_data.replace("<", r"\u003c").replace(
        ">", r"\u003e")

    response = werkzeug_wrappers.Response(
        rendered_data,
        status=status,
        content_type="application/json; charset=utf-8")
    response.headers[
        "Content-Disposition"] = "attachment; filename=response.json"
    response.headers["X-Content-Type-Options"] = "nosniff"

    if token and token.reason:
      response.headers["X-GRR-Reason"] = utils.SmartStr(token.reason)
    if method_name:
      response.headers["X-API-Method"] = method_name
    if no_audit_log:
      response.headers["X-No-Log"] = "True"

    for key, value in iteritems(headers or {}):
      response.headers[key] = value

    if content_length is not None:
      response.content_length = content_length

    return response
5593
function (event){
		//IE compatibility
		event = event || window.event;
		//Mozilla, Opera, & Legacy
		if(event && event.type && (/DOMContentLoaded|load/).test(event.type)) {
			fireDOMReady();
		//Legacy	
		} else if(document.readyState) {
			if ((/loaded|complete/).test(doc.readyState)) {
				fireDOMReady();
			//IE, courtesy of Diego Perini (http://javascript.nwbox.com/IEContentLoaded/)
			} else if(document.documentElement.doScroll) {
				try {
					ready || document.documentElement.doScroll('left');
				} catch(ex) {
					return;
				}
				//If no error was thrown, the DOM must be ready
				fireDOMReady();
			}
		}
	}
854632
function send (req, res, status, headers, message) {
  function write () {
    // response body
    var body = createHtmlDocument(message)

    // response status
    res.statusCode = status
    res.statusMessage = statuses[status]

    // response headers
    setHeaders(res, headers)

    // security headers
    res.setHeader('Content-Security-Policy', "default-src 'none'")
    res.setHeader('X-Content-Type-Options', 'nosniff')

    // standard headers
    res.setHeader('Content-Type', 'text/html; charset=utf-8')
    res.setHeader('Content-Length', Buffer.byteLength(body, 'utf8'))

    if (req.method === 'HEAD') {
      res.end()
      return
    }

    res.end(body, 'utf8')
  }

  if (isFinished(req)) {
    write()
    return
  }

  // unpipe everything from the request
  unpipe(req)

  // flush the request
  onFinished(req, write)
  req.resume()
}
890886
function loadScript(url, callback, errorCallback, $timeout) {
    var script = document.createElement('script'),
      body = document.getElementsByTagName('body')[0],
      removed = false;

    script.type = 'text/javascript';
    if (script.readyState) { // IE
      script.onreadystatechange = function () {
        if (script.readyState === 'complete' ||
            script.readyState === 'loaded') {
          script.onreadystatechange = null;
          $timeout(
            function () {
              if (removed) return;
              removed = true;
              body.removeChild(script);
              callback();
            }, 30, false);
        }
      };
    } else { // Others
      script.onload = function () {
        if (removed) return;
        removed = true;
        body.removeChild(script);
        callback();
      };
      script.onerror = function () {
        if (removed) return;
        removed = true;
        body.removeChild(script);
        errorCallback();
      };
    }
    script.src = url;
    script.async = false;
    body.appendChild(script);
  }
94822
function () {
            if (this._enableIEpolling) {
                this._hashPollCallback = ariaCoreTimer.addCallback({
                    fn : this._hashPoll,
                    scope : this,
                    delay : this.ie7PollDelay
                });

                var documentHash = this.getHashString();

                var iframeHash = this.polledIframeHashString;

                // back or forward
                if (iframeHash != this._currentIframeHashString) {
                    this._currentIframeHashString = iframeHash;
                    this._currentHashString = iframeHash;
                    this.setHash(iframeHash);
                    this._internalCallback();
                } else if (documentHash != this._currentHashString) {// no back or forward
                    this._addIframeHistoryEntry(documentHash);
                    this._internalCallback();
                }
            }
        }
440194
function _onFrameNavigated(event, res) {
        // res = {frame}
        // Re-inject RemoteFunctions when navigating to a new page, but not if an iframe was loaded
        if (res.frame.parentId) {
            return;
        }

        _stopKeepAliveInterval();

        // inject RemoteFunctions
        var command = "window._LD=" + RemoteFunctions + "(" + JSON.stringify(LiveDevelopment.config) + "," + PreferencesManager.get("livedev.wsPort") + ");";

        Inspector.Runtime.evaluate(command, function onEvaluate(response) {
            if (response.error || response.wasThrown) {
                _load.reject(response.error);
            } else {
                _objectId = response.result.objectId;
                _load.resolve();

                _startKeepAliveInterval();
            }
        });
    }
580042
function parseResponse({ browser, history, document, response }) {
  const window      = document.defaultView;
  window._request   = response.request;
  window._response  = response;
  history.updateLocation(window, response._url);

  const done = window._eventQueue.waitForCompletion();
  response
    ._consume()
    .then(function(body) {

      const contentType = response.headers.get('Content-Type') || '';
      const html        = getHTMLFromResponseBody(body, contentType);
      response.body     = html;
      document.write(html || '<html></html>');
      document.close();

      browser.emit('loaded', document);
      if (response.status >= 400)
        throw new Error(`Server returned status code ${response.status} from ${response.url}`);
      if (!document.documentElement)
        throw new Error(`Could not parse document at ${response.url}`);

    })
    .then(function() {

      // Handle meta refresh.  Automatically reloads new location and counts
      // as a redirect.
      //
      // If you need to check the page before refresh takes place, use this:
      //   browser.wait({
      //     function: function() {
      //       return browser.query('meta[http-equiv="refresh"]');
      //     }
      //   });
      const refresh = getMetaRefresh(document);

      if (refresh) {
        const { refreshTimeout } = refresh;
        const { refreshURL }     = refresh;

        window._eventQueue.setTimeout(function() {
          // Allow completion function to run
          window._eventQueue.enqueue(function() {
            window._eventQueue.enqueue(function() {
              // Count a meta-refresh in the redirects count.
              history.replace(refreshURL);
              // This results in a new window getting loaded
              const newWindow = history.current.window;
              newWindow.addEventListener('load', function() {
                ++newWindow._request._redirectCount;
              });
            });
          });
        }, refreshTimeout * 1000);
      }

    })
    .catch(function(error) {
      browser.emit('error', error);
    })
    .then(done);
}
1066608
function _send(level, args) {
  var payload = (
    'level=' + encodeURIComponent(level) +
    '&message=' + encodeURIComponent(args.join(' ')));

  var xhr = new XMLHttpRequest();
  xhr.open('POST', '/log');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  xhr.onreadystatechange = function () {
    // Check for error state
    if (xhr.readyState === 4 && xhr.status !== 200) {
      // TODO: Notify user on the page and show message if console.log doesn't exist
      if (console && console.log) {
        console.log(xhr.responseText);
      }
    }
  };
  xhr.send(payload);
}
529318
function(){
                // Remove the handler
                var w = callerWindow || this;
                un(w, "load", onLoad);
                easyXDM.Fn.set(config.channel + "_load", _onLoad);
                (function test(){
                    if (typeof w.contentWindow.sendMessage == "function") {
                        _onReady();
                    }
                    else {
                        setTimeout(test, 50);
                    }
                }());
            }
762274
function(url) {
		var dfd = $.Deferred(),
			ifm;
		try {
			ifm = $('<iframe width="1" height="1" scrolling="no" frameborder="no" style="position:absolute; top:-1px; left:-1px" crossorigin="use-credentials">')
				.attr('src', url)
				.one('load', function() {
					var ifm = $(this);
					try {
						this.contentDocument.location.reload(true);
						ifm.one('load', function() {
							ifm.remove();
							dfd.resolve();
						});
					} catch(e) {
						ifm.attr('src', '').attr('src', url).one('load', function() {
							ifm.remove();
							dfd.resolve();
						});
					}
				})
				.appendTo('body');
		} catch(e) {
			ifm && ifm.remove();
			dfd.reject();
		}
		return dfd;
	}
1153959
function deferClickEvent(evt, anchor, callback){
  var timeout = 500,
      targetAttr,
      cbResponse;

  // Get 'target' attribute from anchor
  if (anchor.getAttribute !== void 0) {
    targetAttr = anchor.getAttribute("target");
  } else if (anchor.target) {
    targetAttr = anchor.target;
  }

  // Fire listener and catch possible response (return false)
  cbResponse = callback(evt);

  // If prevented within callback, bail:
  if (('boolean' === typeof cbResponse && cbResponse === false) || evt.defaultPrevented || evt.returnValue === false) {
    if (evt.preventDefault) {
      evt.preventDefault();
    }
    evt.returnValue = false;
    return false;
  }
  // Else if anchor doesn't kick off a new window or tab.. defer and replay the event:
  else if (targetAttr !== '_blank' && targetAttr !== 'blank' && !evt.metaKey && !anchor.hasAttribute('download')) {
    if (evt.preventDefault) {
      evt.preventDefault();
    }
    evt.returnValue = false;
    if (
      anchor.href
      && anchor.href !== '#'
      && anchor.href !== (window.location + '#')
    ) {
      if (typeof cbResponse !== 'undefined') {
        if (navigator && navigator.sendBeacon) {
          window.location = anchor.href;
          return;
        }
        // promise
        cbResponse.then(() => {
          window.location = anchor.href;
        }).catch(err => {
          // change location anyway - to not let user hanging
          window.location = anchor.href;
        });
      } else {
        setTimeout(function(){
          window.location = anchor.href;
        }, timeout);
      }
    }
  }

  return false;
}
109524
function()
		{
			var $ = this.$;

			try
			{
				// In IE, with custom document.domain, it may happen that
				// the iframe is not yet available, resulting in "Access
				// Denied" for the following property access.
				$.contentWindow.document;
			}
			catch ( e )
			{
				// Trick to solve this issue, forcing the iframe to get ready
				// by simply setting its "src" property.
				$.src = $.src;

				// In IE6 though, the above is not enough, so we must pause the
				// execution for a while, giving it time to think.
				if ( CKEDITOR.env.ie && CKEDITOR.env.version < 7 )
				{
					window.showModalDialog(
						'javascript:document.write("' +
							'<script>' +
								'window.setTimeout(' +
									'function(){window.close();}' +
									',50);' +
							'</script>")' );
				}
			}

			return $ && new CKEDITOR.dom.document( $.contentWindow.document );
		}
173129
function send() {
  'use strict';
  var req = new XMLHttpRequest(),
    specs = jsApiReporter.specs(),
    payload;

  if (specs.length) {
    specs.push(logs);
  }
  payload = JSON.stringify(specs);

  req.open('post', 'http://localhost:' + port + '/put', true);
  req.onload = function () {
    if (this.responseText === 'kill') {
      chrome.app.window.current().close();
    }
  };
  req.send(payload);
}