Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / test / ispy / client / dom.py
blobfacac134e614e4a7d0f38be9ce3a730b84a93764
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6 def GetScriptToWaitForUnchangingDOM():
7 """Gets Javascript that waits until the DOM is stable for 5 seconds.
9 Times out if the DOM is not stable within 30 seconds.
11 Returns:
12 Javascript as a string.
13 """
14 return """
15 var target = document.body;
16 var callback = arguments[arguments.length - 1]
18 var timeout_id = setTimeout(function() {
19 callback()
20 }, 5000);
22 var observer = new MutationObserver(function(mutations) {
23 clearTimeout(timeout_id);
24 timeout_id = setTimeout(function() {
25 callback();
26 }, 5000);
27 }).observe(target, {attributes: true, childList: true,
28 characterData: true, subtree: true});
29 """