Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / executescript / user_gesture / test.js
blob7e89c64644e58da76e8e531590b9b70c19a92b6b
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.
5 var relativePath =
6     '/extensions/api_test/executescript/run_at/test.html';
7 var testUrl = 'http://b.com:PORT' + relativePath;
9 chrome.test.getConfig(function(config) {
10   testUrl = testUrl.replace(/PORT/, config.testServer.port);
11   chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
12     if (changeInfo.status != 'complete')
13       return;
14     chrome.tabs.onUpdated.removeListener(arguments.callee);
16     chrome.test.runTests([
17       function passUserGestureToExecutedScript() {
18         chrome.runtime.onMessage.addListener(
19             chrome.test.callbackPass(function(request, sender, sendResponse) {
20                 // The script executed by executeScript should run in a
21                 // user gesture context.
22                 chrome.test.assertTrue(request.user_gesture);
23             })
24         );
25         var code = "chrome.runtime.sendMessage({" +
26                    "    user_gesture: chrome.test.isProcessingUserGesture()});"
27         chrome.test.runWithUserGesture(function() {
28           chrome.tabs.executeScript(tabId, {code: code});
29         });
30       }
31     ]);
32   });
33   chrome.tabs.create({ url: testUrl });
34 });