1 // Copyright 2013 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 var URL
= chrome
.extension
.getURL("a.html");
6 var URL_FRAMES
= chrome
.extension
.getURL("b.html");
10 chrome
.test
.runTests([
11 function testGetFrame() {
12 chrome
.tabs
.create({"url": "about:blank"}, function(tab
) {
14 var done
= chrome
.test
.listenForever(
15 chrome
.webNavigation
.onCommitted
,
17 if (details
.tabId
!= tabId
)
19 if (details
.url
!= URL
)
21 processId
= details
.processId
;
22 chrome
.webNavigation
.getFrame(
23 {tabId
: tabId
, frameId
: 0, processId
: processId
},
26 {errorOccurred
: false, url
: URL
, parentFrameId
: -1},
31 chrome
.tabs
.update(tabId
, {url
: URL
});
35 function testGetInvalidFrame() {
36 chrome
.webNavigation
.getFrame(
37 {tabId
: tabId
, frameId
: 1, processId
: processId
},
39 chrome
.test
.assertEq(null, details
);
40 chrome
.test
.succeed();
44 function testGetAllFrames() {
45 chrome
.webNavigation
.getAllFrames(
49 [{errorOccurred
: false,
55 chrome
.test
.succeed();
59 // Load an URL with a frame which is detached during load. getAllFrames should
60 // only return the remaining (main) frame.
61 function testFrameDetach() {
62 chrome
.tabs
.create({"url": "about:blank"}, function(tab
) {
64 var done
= chrome
.test
.listenForever(
65 chrome
.webNavigation
.onCommitted
,
67 if (details
.tabId
!= tabId
)
69 if (details
.url
!= URL_FRAMES
)
71 processId
= details
.processId
;
72 chrome
.webNavigation
.getAllFrames(
76 [{errorOccurred
: false,
82 chrome
.test
.succeed();
85 chrome
.tabs
.update(tabId
, {url
: URL_FRAMES
});