Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / mutation_observers / background.js
blob8c78aa8e5409ac67a7131b5a4f5879c729983f60
1 // Copyright (c) 2012 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.
5 window.addEventListener('DOMContentLoaded', function() {
6 var body = document.body;
7 var div = body.appendChild(document.createElement('div'));
8 var input1 = body.appendChild(document.createElement('input'));
9 var input2 = body.appendChild(document.createElement('input'));
11 input1.focus();
12 input1.addEventListener('blur', function() {
13 div.setAttribute('baz', 'bat');
14 });
16 var success = false;
17 var mutationsDelivered = false;
19 var observer = new MutationObserver(function() {
20 mutationsDelivered = true;
21 if (success)
22 chrome.test.succeed();
23 });
24 observer.observe(document, { subtree: true, attributes: true });
26 // The getAll callback should be counted as a V8RecursionScope and cause
27 // the delivery of MutationRecords to be delayed until it has exited.
28 chrome.windows.getAll(function() {
29 div.setAttribute('foo', 'bar');
30 input2.focus();
31 if (mutationsDelivered)
32 chrome.test.fail();
33 else
34 success = true;
35 });
36 });