Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 function dartPrint(msg) { | |
| 6 window.parent.postMessage(String(msg), "*"); | |
| 7 } | |
| 8 | |
| 9 window.onerror = function (message, url, lineNumber) { | |
| 10 window.parent.postMessage( | |
| 11 ["error", {message: message, url: url, lineNumber: lineNumber}], "*"); | |
| 12 }; | |
| 13 | |
| 14 function onMessageReceived(event) { | |
| 15 var data = event.data; | |
| 16 if (data instanceof Array) { | |
| 17 if (data.length == 2 && data[0] == 'source') { | |
| 18 var script = document.createElement('script'); | |
| 19 script.innerHTML = data[1]; | |
| 20 script.type = 'application/javascript'; | |
| 21 document.head.appendChild(script); | |
| 22 return; | |
|
kasperl
2014/01/07 07:18:43
Do you really need this return?
ahe
2014/01/07 14:06:23
No, but it makes it easier to add new cases.
| |
| 23 } | |
| 24 } | |
| 25 } | |
| 26 | |
| 27 window.addEventListener("message", onMessageReceived, false); | |
| 28 | |
| 29 (function () { | |
| 30 function postScrollHeight() { | |
| 31 window.parent.postMessage(["scrollHeight", document.documentElement.scrollHeig ht], "*"); | |
|
kasperl
2014/01/07 07:18:43
Long line.
ahe
2014/01/07 14:06:23
Done.
| |
| 32 } | |
| 33 | |
| 34 var observer = new (window.MutationObserver||window.WebKitMutationObserver||wind ow.MozMutationObserver)(function(mutations) { | |
|
kasperl
2014/01/07 07:18:43
Long line.
ahe
2014/01/07 14:06:23
Done.
| |
| 35 postScrollHeight() | |
| 36 window.setTimeout(postScrollHeight, 500); | |
| 37 }); | |
| 38 | |
| 39 observer.observe( | |
| 40 document.body, | |
| 41 { attributes: true, | |
| 42 childList: true, | |
| 43 characterData: true, | |
| 44 subtree: true }); | |
| 45 })(); | |
| OLD | NEW |