| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var pass = chrome.test.callbackPass; | 5 var pass = chrome.test.callbackPass; |
| 6 var fail = chrome.test.callbackFail; | 6 var fail = chrome.test.callbackFail; |
| 7 var assertEq = chrome.test.assertEq; | 7 var assertEq = chrome.test.assertEq; |
| 8 var assertTrue = chrome.test.assertTrue; | 8 var assertTrue = chrome.test.assertTrue; |
| 9 var relativePath = '/extensions/api_test/executescript/frame_id/frames.html'; | 9 var relativePath = '/extensions/api_test/executescript/frame_id/frames.html'; |
| 10 var testOrigin = 'http://a.com:PORT'; | 10 var testOrigin = 'http://a.com:PORT'; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 matchAboutBlank: true, | 140 matchAboutBlank: true, |
| 141 code: 'document.URL' | 141 code: 'document.URL' |
| 142 }, | 142 }, |
| 143 pass(function(results) { | 143 pass(function(results) { |
| 144 assertEq(1, results.length); | 144 assertEq(1, results.length); |
| 145 assertTrue(matchesAny(results, R_FRAME_SRCDOC)); | 145 assertTrue(matchesAny(results, R_FRAME_SRCDOC)); |
| 146 })); | 146 })); |
| 147 }, | 147 }, |
| 148 | 148 |
| 149 function executeScriptInSrcdocFrameWithoutMatchAboutBlank() { | 149 function executeScriptInSrcdocFrameWithoutMatchAboutBlank() { |
| 150 // TODO(robwu): Why is the origin serialized as "about:blank" instead of | |
| 151 // "about:srcdoc"? | |
| 152 chrome.tabs.executeScript( | 150 chrome.tabs.executeScript( |
| 153 tabId, {frameId: ID_FRAME_SRCDOC, code: 'document.URL'}, | 151 tabId, {frameId: ID_FRAME_SRCDOC, code: 'document.URL'}, |
| 154 fail( | 152 fail( |
| 155 'Cannot access "about:blank" at origin "' + testOrigin + '". ' + | 153 'Cannot access "about:srcdoc" at origin "' + testOrigin + '". ' + |
| 156 'Extension must have permission to access the frame\'s origin, ' + | 154 'Extension must have permission to access the frame\'s origin, ' + |
| 157 'and matchAboutBlank must be true.')); | 155 'and matchAboutBlank must be true.')); |
| 158 }, | 156 }, |
| 159 | 157 |
| 160 function executeScriptInSrcdocFrameIncludingAllFrames() { | 158 function executeScriptInSrcdocFrameIncludingAllFrames() { |
| 161 chrome.tabs.executeScript( | 159 chrome.tabs.executeScript( |
| 162 tabId, { | 160 tabId, { |
| 163 frameId: ID_FRAME_SRCDOC, | 161 frameId: ID_FRAME_SRCDOC, |
| 164 matchAboutBlank: true, | 162 matchAboutBlank: true, |
| 165 allFrames: true, | 163 allFrames: true, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 function insertCSSInSrcdocFrame() { | 274 function insertCSSInSrcdocFrame() { |
| 277 insertCSS( | 275 insertCSS( |
| 278 tabId, {frameId: ID_FRAME_SRCDOC, matchAboutBlank: true}, | 276 tabId, {frameId: ID_FRAME_SRCDOC, matchAboutBlank: true}, |
| 279 pass(function(results) { | 277 pass(function(results) { |
| 280 assertEq(1, results.length); | 278 assertEq(1, results.length); |
| 281 assertTrue(matchesAny(results, R_FRAME_SRCDOC)); | 279 assertTrue(matchesAny(results, R_FRAME_SRCDOC)); |
| 282 })); | 280 })); |
| 283 }, | 281 }, |
| 284 | 282 |
| 285 function insertCSSInSrcdocFrameWithoutMatchAboutBlank() { | 283 function insertCSSInSrcdocFrameWithoutMatchAboutBlank() { |
| 286 // TODO(robwu): Why is the origin serialized as "about:blank" instead of | |
| 287 // "about:srcdoc"? | |
| 288 chrome.tabs.insertCSS( | 284 chrome.tabs.insertCSS( |
| 289 tabId, {frameId: ID_FRAME_SRCDOC, code: 'body{color:red;}'}, | 285 tabId, {frameId: ID_FRAME_SRCDOC, code: 'body{color:red;}'}, |
| 290 fail( | 286 fail( |
| 291 'Cannot access "about:blank" at origin "' + testOrigin + '". ' + | 287 'Cannot access "about:srcdoc" at origin "' + testOrigin + '". ' + |
| 292 'Extension must have permission to access the frame\'s origin, ' + | 288 'Extension must have permission to access the frame\'s origin, ' + |
| 293 'and matchAboutBlank must be true.')); | 289 'and matchAboutBlank must be true.')); |
| 294 }, | 290 }, |
| 295 | 291 |
| 296 function insertCSSInSrcdocFrameIncludingAllFrames() { | 292 function insertCSSInSrcdocFrameIncludingAllFrames() { |
| 297 insertCSS( | 293 insertCSS( |
| 298 tabId, | 294 tabId, |
| 299 {frameId: ID_FRAME_SRCDOC, matchAboutBlank: true, allFrames: true}, | 295 {frameId: ID_FRAME_SRCDOC, matchAboutBlank: true, allFrames: true}, |
| 300 pass(function(results) { | 296 pass(function(results) { |
| 301 assertEq(1, results.length); | 297 assertEq(1, results.length); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 assertEq( | 370 assertEq( |
| 375 'Invalid value for argument 2. Property \'frameId\': ' + | 371 'Invalid value for argument 2. Property \'frameId\': ' + |
| 376 'Value must not be less than 0.', | 372 'Value must not be less than 0.', |
| 377 e.message); | 373 e.message); |
| 378 chrome.test.succeed(); | 374 chrome.test.succeed(); |
| 379 } | 375 } |
| 380 }, | 376 }, |
| 381 | 377 |
| 382 ]); | 378 ]); |
| 383 } | 379 } |
| OLD | NEW |