Commit 1cd72d23 authored by abarth@chromium.org's avatar abarth@chromium.org

Move yet another block of tests to manifest_version 2

BUG=62897
TBR=aa
Review URL: http://codereview.chromium.org/8763008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112591 0039d316-1c4b-4281-b951-d872f2087c98
parent 225dc0cc
<script>
var fileSystem = null;
var testDirName = "tmp/test_dir_" + Math.floor(Math.random()*10000);
var testFileName = "test_file_" + Math.floor(Math.random()*10000);
// Get local FS, create dir with a file in it.
console.log("Requesting local file system...");
chrome.fileBrowserPrivate.requestLocalFileSystem(getFileSystem);
function getFileSystem(fs, error) {
if (!fs) {
errorCallback(error);
return;
}
fileSystem = fs;
console.log("DONE requesting local filesystem: " + fileSystem.name);
console.log("Creating directory : " + testDirName);
fileSystem.root.getDirectory(testDirName, {create:true},
directoryCallback, errorCallback);
}
function directoryCallback(directory) {
console.log("DONE creating directory: " + directory.fullPath);
directory.getFile(testFileName, {create:true}, fileCallback, errorCallback);
}
function fileCallback(file) {
console.log("DONE creating file: " + file.fullPath);
// See if we can access this filesystem and its elements in the tab.
console.log("Opening tab...");
chrome.tabs.create({
url: "tab.html#" + escape(testDirName + "/" + testFileName)
});
}
function errorCallback(e) {
var msg = '';
switch (e.code) {
case FileError.QUOTA_EXCEEDED_ERR:
msg = 'QUOTA_EXCEEDED_ERR';
break;
case FileError.NOT_FOUND_ERR:
msg = 'NOT_FOUND_ERR';
break;
case FileError.SECURITY_ERR:
msg = 'SECURITY_ERR';
break;
case FileError.INVALID_MODIFICATION_ERR:
msg = 'INVALID_MODIFICATION_ERR';
break;
case FileError.INVALID_STATE_ERR:
msg = 'INVALID_STATE_ERR';
break;
default:
msg = 'Unknown Error';
break;
};
chrome.test.fail("Got unexpected error: " + msg);
console.log('Error: ' + msg);
alert('Error: ' + msg);
}
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="background.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var fileSystem = null;
var testDirName = "tmp/test_dir_" + Math.floor(Math.random()*10000);
var testFileName = "test_file_" + Math.floor(Math.random()*10000);
// Get local FS, create dir with a file in it.
console.log("Requesting local file system...");
chrome.fileBrowserPrivate.requestLocalFileSystem(getFileSystem);
function getFileSystem(fs, error) {
if (!fs) {
errorCallback(error);
return;
}
fileSystem = fs;
console.log("DONE requesting local filesystem: " + fileSystem.name);
console.log("Creating directory : " + testDirName);
fileSystem.root.getDirectory(testDirName, {create:true},
directoryCallback, errorCallback);
}
function directoryCallback(directory) {
console.log("DONE creating directory: " + directory.fullPath);
directory.getFile(testFileName, {create:true}, fileCallback, errorCallback);
}
function fileCallback(file) {
console.log("DONE creating file: " + file.fullPath);
// See if we can access this filesystem and its elements in the tab.
console.log("Opening tab...");
chrome.tabs.create({
url: "tab.html#" + escape(testDirName + "/" + testFileName)
});
}
function errorCallback(e) {
var msg = '';
switch (e.code) {
case FileError.QUOTA_EXCEEDED_ERR:
msg = 'QUOTA_EXCEEDED_ERR';
break;
case FileError.NOT_FOUND_ERR:
msg = 'NOT_FOUND_ERR';
break;
case FileError.SECURITY_ERR:
msg = 'SECURITY_ERR';
break;
case FileError.INVALID_MODIFICATION_ERR:
msg = 'INVALID_MODIFICATION_ERR';
break;
case FileError.INVALID_STATE_ERR:
msg = 'INVALID_STATE_ERR';
break;
default:
msg = 'Unknown Error';
break;
};
chrome.test.fail("Got unexpected error: " + msg);
console.log('Error: ' + msg);
alert('Error: ' + msg);
}
......@@ -2,6 +2,7 @@
"key": "MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDJ5+2VmV02HP3jkMhxbp2yuyzf4K4JsffgCf8zsPljLVV2A+JXGj0TbvzvDP3RDCKC5qPMprQkoYlKVW2b6H0kQ8dNmZsjxMqEz/ZDx4Z6/VvbMaz8pP+dENs5Io5XlG5Op2nsJF+y+LqbX6qbff9D/s4fTWyqKillpJN+48qs0wIBIw==",
"name": "chromeos.local filesystem",
"version": "0.1",
"manifest_version": 2,
"description": "Local filesystem access sanity test",
"background_page": "background.html",
"permissions": [
......
<script>
var fileSystem = null;
var testDirName = null;
var testFileName = null;
var watchfileUrl = null;
function errorCallback(e) {
var msg = '';
switch (e.code) {
case FileError.QUOTA_EXCEEDED_ERR:
msg = 'QUOTA_EXCEEDED_ERR';
break;
case FileError.NOT_FOUND_ERR:
msg = 'NOT_FOUND_ERR';
break;
case FileError.SECURITY_ERR:
msg = 'SECURITY_ERR';
break;
case FileError.INVALID_MODIFICATION_ERR:
msg = 'INVALID_MODIFICATION_ERR';
break;
case FileError.INVALID_STATE_ERR:
msg = 'INVALID_STATE_ERR';
break;
default:
msg = 'Unknown Error';
break;
};
chrome.test.fail("Got unexpected error: " + msg);
console.log('Error: ' + msg);
alert('Error: ' + msg);
}
function successCallbackFinal(entry) {
chrome.test.succeed();
}
function onGetFileEntry(entry) {
chrome.test.succeed();
}
function deleteDirectory() {
console.log("Deleting dir : " + testDirName);
fileSystem.root.getDirectory(testDirName, {create:false},
function(directory) {
// Do clean-up. (Assume the tab won't be reloaded in testing.)
directory.removeRecursively(successCallbackFinal, errorCallback);
}, errorCallback);
}
// Sets up directory watch, kicks of file removal from the directory.
function setupDirectoryWatch(dirEntry) {
watchfileUrl = dirEntry.toURL();
chrome.fileBrowserPrivate.addFileWatch(
watchfileUrl,
function(success) {
if (!success) {
chrome.test.fail("File watch setup failed.");
} else {
console.log("Added new file watch: " + watchfileUrl);
fileSystem.root.getFile(testDirName+'/'+testFileName, {create: false},
triggerFolderChange, errorCallback);
}
});
}
function triggerFolderChange(fileEntry) {
// Just delete test file, this should trigger onFolderChanged call below.
fileEntry.remove(function() {}, errorCallback);
}
function onFolderChanged(info) {
if (info && info.eventType == 'changed' &&
info.fileUrl == watchfileUrl) {
// Remove file watch.
console.log("Removing file watch: " + info.fileUrl);
chrome.fileBrowserPrivate.removeFileWatch(info.fileUrl,
function(success) {
if (success) {
chrome.test.succeed();
} else {
chrome.test.fail("Failed to remove file watch.");
}
});
} else {
var msg = "ERROR: Unexpected watch event info";
console.log(msg);
console.log(info);
chrome.test.fail(msg);
}
}
function onLocalFS(fs, error) {
if (!fs) {
errorCallback(error);
return;
}
fileSystem = fs;
console.log("DONE requesting filesystem: " + fileSystem.name);
// Read directory content.
console.log("Opening file : " + testDirName+'/'+testFileName);
fileSystem.root.getDirectory(testDirName, {create: false},
function(dirEntry) {
console.log('DONE opening directory: ' + dirEntry.fullPath);
fileSystem.root.getFile(testDirName+'/'+testFileName, {create:false},
onGetFileEntry, errorCallback);
}, errorCallback);
}
// Initialize tests - get test dir, file name.
function start() {
var loc = window.location.href;
console.log("Opening tab " + loc);
if (loc.indexOf("#") == -1 ) {
chrome.test.fail("Missing params");
return;
}
loc = unescape(loc.substr(loc.indexOf("#") + 1));
if (loc.lastIndexOf("/") == -1 ) {
chrome.test.fail("Bad params");
return;
}
testDirName = loc.substr(0, loc.lastIndexOf("/"));
testFileName = loc.substr(loc.lastIndexOf("/") + 1);
chrome.test.runTests([
function basic_operations() {
console.log("Requesting local file system...");
chrome.fileBrowserPrivate.requestLocalFileSystem(onLocalFS);
},
function file_watcher() {
chrome.fileBrowserPrivate.onFileChanged.addListener(onFolderChanged);
console.log("Setting up watch of : " + testDirName);
fileSystem.root.getDirectory(testDirName, {create: false},
setupDirectoryWatch, errorCallback);
},
function cleanup() {
deleteDirectory();
}
]);
}
start();
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="tab.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var fileSystem = null;
var testDirName = null;
var testFileName = null;
var watchfileUrl = null;
function errorCallback(e) {
var msg = '';
switch (e.code) {
case FileError.QUOTA_EXCEEDED_ERR:
msg = 'QUOTA_EXCEEDED_ERR';
break;
case FileError.NOT_FOUND_ERR:
msg = 'NOT_FOUND_ERR';
break;
case FileError.SECURITY_ERR:
msg = 'SECURITY_ERR';
break;
case FileError.INVALID_MODIFICATION_ERR:
msg = 'INVALID_MODIFICATION_ERR';
break;
case FileError.INVALID_STATE_ERR:
msg = 'INVALID_STATE_ERR';
break;
default:
msg = 'Unknown Error';
break;
};
chrome.test.fail("Got unexpected error: " + msg);
console.log('Error: ' + msg);
alert('Error: ' + msg);
}
function successCallbackFinal(entry) {
chrome.test.succeed();
}
function onGetFileEntry(entry) {
chrome.test.succeed();
}
function deleteDirectory() {
console.log("Deleting dir : " + testDirName);
fileSystem.root.getDirectory(testDirName, {create:false},
function(directory) {
// Do clean-up. (Assume the tab won't be reloaded in testing.)
directory.removeRecursively(successCallbackFinal, errorCallback);
}, errorCallback);
}
// Sets up directory watch, kicks of file removal from the directory.
function setupDirectoryWatch(dirEntry) {
watchfileUrl = dirEntry.toURL();
chrome.fileBrowserPrivate.addFileWatch(
watchfileUrl,
function(success) {
if (!success) {
chrome.test.fail("File watch setup failed.");
} else {
console.log("Added new file watch: " + watchfileUrl);
fileSystem.root.getFile(testDirName+'/'+testFileName, {create: false},
triggerFolderChange, errorCallback);
}
});
}
function triggerFolderChange(fileEntry) {
// Just delete test file, this should trigger onFolderChanged call below.
fileEntry.remove(function() {}, errorCallback);
}
function onFolderChanged(info) {
if (info && info.eventType == 'changed' &&
info.fileUrl == watchfileUrl) {
// Remove file watch.
console.log("Removing file watch: " + info.fileUrl);
chrome.fileBrowserPrivate.removeFileWatch(info.fileUrl,
function(success) {
if (success) {
chrome.test.succeed();
} else {
chrome.test.fail("Failed to remove file watch.");
}
});
} else {
var msg = "ERROR: Unexpected watch event info";
console.log(msg);
console.log(info);
chrome.test.fail(msg);
}
}
function onLocalFS(fs, error) {
if (!fs) {
errorCallback(error);
return;
}
fileSystem = fs;
console.log("DONE requesting filesystem: " + fileSystem.name);
// Read directory content.
console.log("Opening file : " + testDirName+'/'+testFileName);
fileSystem.root.getDirectory(testDirName, {create: false},
function(dirEntry) {
console.log('DONE opening directory: ' + dirEntry.fullPath);
fileSystem.root.getFile(testDirName+'/'+testFileName, {create:false},
onGetFileEntry, errorCallback);
}, errorCallback);
}
// Initialize tests - get test dir, file name.
function start() {
var loc = window.location.href;
console.log("Opening tab " + loc);
if (loc.indexOf("#") == -1 ) {
chrome.test.fail("Missing params");
return;
}
loc = unescape(loc.substr(loc.indexOf("#") + 1));
if (loc.lastIndexOf("/") == -1 ) {
chrome.test.fail("Bad params");
return;
}
testDirName = loc.substr(0, loc.lastIndexOf("/"));
testFileName = loc.substr(loc.lastIndexOf("/") + 1);
chrome.test.runTests([
function basic_operations() {
console.log("Requesting local file system...");
chrome.fileBrowserPrivate.requestLocalFileSystem(onLocalFS);
},
function file_watcher() {
chrome.fileBrowserPrivate.onFileChanged.addListener(onFolderChanged);
console.log("Setting up watch of : " + testDirName);
fileSystem.root.getDirectory(testDirName, {create: false},
setupDirectoryWatch, errorCallback);
},
function cleanup() {
deleteDirectory();
}
]);
}
start();
{
"name": "description",
"version": "0.1",
"manifest_version": 2,
"description" : "a short description"
}
{
"name": "disabled_app",
"version": "0.1",
"manifest_version": 2,
"app": {
"launch": {
"web_url": "http://www.google.com"
......
{
"name": "disabled_extension",
"version": "0.1",
"manifest_version": 2,
"options_page": "pages/options.html"
}
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
</html>
{
"name": "enabled_app",
"version": "0.1",
"manifest_version": 2,
"app": {
"launch": {
"web_url": "http://www.google.com"
......
{
"name": "enabled_extension",
"version": "0.1",
"manifest_version": 2,
"icons": {
"128": "icon_128.png",
"48": "icon_48.png",
......
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<head>
<title>App launch page</title>
......
{
"name": "Launch App in Panel",
"version": "1",
"manifest_version": 2,
"permissions": ["management"],
"app": {
"launch": {
......
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<head>
<title>App launch page</title>
......
{
"name": "Launch App in a tab",
"version": "1",
"manifest_version": 2,
"permissions": ["management"],
"app": {
"launch": {
......
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<head>
<script src="background.js"></script>
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.management.onInstalled.addListener(function(extensionInfo) {
if (!extensionInfo.isApp) {
......
{
"name": "Launch App on Install (test extension)",
"version": "1",
"manifest_version": 2,
"permissions": ["management"],
"background_page": "background.html"
}
{
"name": "permissions",
"version": "0.1",
"manifest_version": 2,
"permissions": ["unlimitedStorage", "notifications", "http://*/*"]
}
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="common.js"></script>
<script src="basics.js"></script>
{
"name": "Extension Management API Test",
"version": "0.1",
"manifest_version": 2,
"permissions": ["management"]
}
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="common.js"></script>
<script src="uninstall.js"></script>
{
"name": "connect_external",
"version": "1.0",
"manifest_version": 2,
"description": "Tests connect from a content script.",
"permissions": ["tabs"],
"background_page": "test.html",
......
<script>
JSON.parse = function() {
return "JSON.parse clobbered by extension.";
};
JSON.stringify = function() {
return "JSON.stringify clobbered by extension.";
};
Array.prototype.toJSON = function() {
return "Array.prototype.toJSON clobbered by extension.";
};
Object.prototype.toJSON = function() {
return "Object.prototype.toJSON clobbered by extension.";
};
// Keep track of the tab that we're running tests in, for simplicity.
var testTab = null;
chrome.test.getConfig(function(config) {
chrome.test.runTests([
function setupTestTab() {
chrome.test.log("Creating tab...");
chrome.tabs.create({
url: "http://localhost:PORT/files/extensions/test_file.html"
.replace(/PORT/, config.testServer.port)
}, function(tab) {
chrome.tabs.onUpdated.addListener(function listener(tabid, info) {
if (tab.id == tabid && info.status == 'complete') {
chrome.test.log("Created tab: " + tab.url);
chrome.tabs.onUpdated.removeListener(listener);
testTab = tab;
chrome.test.succeed();
}
});
});
},
// Tests that postMessage to the tab and its response works.
function postMessage() {
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testPostMessage: true});
port.onMessage.addListener(function(msg) {
port.disconnect();
chrome.test.succeed();
});
},
// Tests that port name is sent & received correctly.
function portName() {
var portName = "lemonjello";
var port = chrome.tabs.connect(testTab.id, {name: portName});
port.postMessage({testPortName: true});
port.onMessage.addListener(function(msg) {
chrome.test.assertEq(msg.portName, portName);
port.disconnect();
chrome.test.succeed();
});
},
// Tests that postMessage from the tab and its response works.
function postMessageFromTab() {
chrome.extension.onConnect.addListener(function(port) {
port.onMessage.addListener(function(msg) {
chrome.test.assertTrue(msg.testPostMessageFromTab);
port.postMessage({success: true, portName: port.name});
chrome.test.log("postMessageFromTab: got message from tab");
});
});
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testPostMessageFromTab: true});
chrome.test.log("postMessageFromTab: sent first message to tab");
port.onMessage.addListener(function(msg) {
port.disconnect();
chrome.test.succeed();
});
},
// Tests receiving a request from a content script and responding.
function sendRequestFromTab() {
var doneListening = chrome.test.listenForever(
chrome.extension.onRequest,
function(request, sender, sendResponse) {
chrome.test.assertTrue("url" in sender.tab, "no tab available.");
chrome.test.assertEq(sender.id, location.host);
if (request.step == 1) {
// Step 1: Page should send another request for step 2.
chrome.test.log("sendRequestFromTab: got step 1");
sendResponse({nextStep: true});
} else {
// Step 2.
chrome.test.assertEq(request.step, 2);
sendResponse();
doneListening();
}
});
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testSendRequestFromTab: true});
port.disconnect();
chrome.test.log("sendRequestFromTab: sent first message to tab");
},
// Tests error handling when sending a request from a content script to an
// invalid extension.
function sendRequestFromTabError() {
chrome.test.listenOnce(
chrome.extension.onRequest,
function(request, sender, sendResponse) {
if (!request.success)
chrome.test.fail();
}
);
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testSendRequestFromTabError: true});
port.disconnect();
chrome.test.log("testSendRequestFromTabError: send 1st message to tab");
},
// Tests error handling when connecting to an invalid extension from a
// content script.
function connectFromTabError() {
chrome.test.listenOnce(
chrome.extension.onRequest,
function(request, sender, sendResponse) {
if (!request.success)
chrome.test.fail();
}
);
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testConnectFromTabError: true});
port.disconnect();
chrome.test.log("testConnectFromTabError: sent 1st message to tab");
},
// Tests sending a request to a tab and receiving a response.
function sendRequest() {
chrome.tabs.sendRequest(testTab.id, {step2: 1}, function(response) {
chrome.test.assertTrue(response.success);
chrome.test.succeed();
});
},
// Tests that we get the disconnect event when the tab disconnect.
function disconnect() {
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testDisconnect: true});
port.onDisconnect.addListener(function() {
chrome.test.succeed();
});
},
// Tests that we get the disconnect event when the tab context closes.
function disconnectOnClose() {
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testDisconnectOnClose: true});
port.onDisconnect.addListener(function() {
chrome.test.succeed();
testTab = null; // the tab is about:blank now.
});
},
]);
});
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="test.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
JSON.parse = function() {
return "JSON.parse clobbered by extension.";
};
JSON.stringify = function() {
return "JSON.stringify clobbered by extension.";
};
Array.prototype.toJSON = function() {
return "Array.prototype.toJSON clobbered by extension.";
};
Object.prototype.toJSON = function() {
return "Object.prototype.toJSON clobbered by extension.";
};
// Keep track of the tab that we're running tests in, for simplicity.
var testTab = null;
chrome.test.getConfig(function(config) {
chrome.test.runTests([
function setupTestTab() {
chrome.test.log("Creating tab...");
chrome.tabs.create({
url: "http://localhost:PORT/files/extensions/test_file.html"
.replace(/PORT/, config.testServer.port)
}, function(tab) {
chrome.tabs.onUpdated.addListener(function listener(tabid, info) {
if (tab.id == tabid && info.status == 'complete') {
chrome.test.log("Created tab: " + tab.url);
chrome.tabs.onUpdated.removeListener(listener);
testTab = tab;
chrome.test.succeed();
}
});
});
},
// Tests that postMessage to the tab and its response works.
function postMessage() {
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testPostMessage: true});
port.onMessage.addListener(function(msg) {
port.disconnect();
chrome.test.succeed();
});
},
// Tests that port name is sent & received correctly.
function portName() {
var portName = "lemonjello";
var port = chrome.tabs.connect(testTab.id, {name: portName});
port.postMessage({testPortName: true});
port.onMessage.addListener(function(msg) {
chrome.test.assertEq(msg.portName, portName);
port.disconnect();
chrome.test.succeed();
});
},
// Tests that postMessage from the tab and its response works.
function postMessageFromTab() {
chrome.extension.onConnect.addListener(function(port) {
port.onMessage.addListener(function(msg) {
chrome.test.assertTrue(msg.testPostMessageFromTab);
port.postMessage({success: true, portName: port.name});
chrome.test.log("postMessageFromTab: got message from tab");
});
});
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testPostMessageFromTab: true});
chrome.test.log("postMessageFromTab: sent first message to tab");
port.onMessage.addListener(function(msg) {
port.disconnect();
chrome.test.succeed();
});
},
// Tests receiving a request from a content script and responding.
function sendRequestFromTab() {
var doneListening = chrome.test.listenForever(
chrome.extension.onRequest,
function(request, sender, sendResponse) {
chrome.test.assertTrue("url" in sender.tab, "no tab available.");
chrome.test.assertEq(sender.id, location.host);
if (request.step == 1) {
// Step 1: Page should send another request for step 2.
chrome.test.log("sendRequestFromTab: got step 1");
sendResponse({nextStep: true});
} else {
// Step 2.
chrome.test.assertEq(request.step, 2);
sendResponse();
doneListening();
}
});
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testSendRequestFromTab: true});
port.disconnect();
chrome.test.log("sendRequestFromTab: sent first message to tab");
},
// Tests error handling when sending a request from a content script to an
// invalid extension.
function sendRequestFromTabError() {
chrome.test.listenOnce(
chrome.extension.onRequest,
function(request, sender, sendResponse) {
if (!request.success)
chrome.test.fail();
}
);
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testSendRequestFromTabError: true});
port.disconnect();
chrome.test.log("testSendRequestFromTabError: send 1st message to tab");
},
// Tests error handling when connecting to an invalid extension from a
// content script.
function connectFromTabError() {
chrome.test.listenOnce(
chrome.extension.onRequest,
function(request, sender, sendResponse) {
if (!request.success)
chrome.test.fail();
}
);
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testConnectFromTabError: true});
port.disconnect();
chrome.test.log("testConnectFromTabError: sent 1st message to tab");
},
// Tests sending a request to a tab and receiving a response.
function sendRequest() {
chrome.tabs.sendRequest(testTab.id, {step2: 1}, function(response) {
chrome.test.assertTrue(response.success);
chrome.test.succeed();
});
},
// Tests that we get the disconnect event when the tab disconnect.
function disconnect() {
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testDisconnect: true});
port.onDisconnect.addListener(function() {
chrome.test.succeed();
});
},
// Tests that we get the disconnect event when the tab context closes.
function disconnectOnClose() {
var port = chrome.tabs.connect(testTab.id);
port.postMessage({testDisconnectOnClose: true});
port.onDisconnect.addListener(function() {
chrome.test.succeed();
testTab = null; // the tab is about:blank now.
});
},
]);
});
{
"name": "connect_external",
"version": "1.0",
"manifest_version": 2,
"description": "Tests connect to an external extension.",
"background_page": "test.html"
}
<script>
var testId = "bjafgdebaacbbbecmhlhpofkepfkgcpa";
chrome.test.runTests([
function connectExternal() {
var port = chrome.extension.connect(testId, {name: "extern"});
port.postMessage({testConnectExternal: true});
port.onMessage.addListener(chrome.test.callbackPass(function(msg) {
chrome.test.assertTrue(msg.success, "Message failed.");
chrome.test.assertEq(msg.senderId, location.host,
"Sender ID doesn't match.");
}));
}
]);
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="test.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var testId = "bjafgdebaacbbbecmhlhpofkepfkgcpa";
chrome.test.runTests([
function connectExternal() {
var port = chrome.extension.connect(testId, {name: "extern"});
port.postMessage({testConnectExternal: true});
port.onMessage.addListener(chrome.test.callbackPass(function(msg) {
chrome.test.assertTrue(msg.success, "Message failed.");
chrome.test.assertEq(msg.senderId, location.host,
"Sender ID doesn't match.");
}));
}
]);
{
"name": "event_url",
"version": "1.0",
"manifest_version": 2,
"description": "Tests messages which require permissions.",
"permissions": ["http://a.com/"],
"background_page": "test.html"
......
<script>
var messages = [];
function messageReceived(data) {
messages.push(data);
}
function evaluateMessages() {
if (messages.length != 3)
chrome.test.notifyFail("Got " + messages.length + " messages instead of 3");
else if (messages[0] != "no restriction" ||
messages[1] != "http://a.com/" ||
messages[2] != "last message")
chrome.test.notifyFail("Got wrong messages: " + messages[0] + ", " +
messages[1] + ", " + messages[2]);
else
chrome.test.notifyPass();
}
chrome.test.onMessage.addListener(function (info) {
messageReceived(info.data);
if (info.lastMessage)
evaluateMessages();
});
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="test.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var messages = [];
function messageReceived(data) {
messages.push(data);
}
function evaluateMessages() {
if (messages.length != 3)
chrome.test.notifyFail("Got " + messages.length + " messages instead of 3");
else if (messages[0] != "no restriction" ||
messages[1] != "http://a.com/" ||
messages[2] != "last message")
chrome.test.notifyFail("Got wrong messages: " + messages[0] + ", " +
messages[1] + ", " + messages[2]);
else
chrome.test.notifyPass();
}
chrome.test.onMessage.addListener(function (info) {
messageReceived(info.data);
if (info.lastMessage)
evaluateMessages();
});
......@@ -2,6 +2,7 @@
"key": "MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDJ5+2VmV02HP3jkMhxbp2yuyzf4K4JsffgCf8zsPljLVV2A+JXGj0TbvzvDP3RDCKC5qPMprQkoYlKVW2b6H0kQ8dNmZsjxMqEz/ZDx4Z6/VvbMaz8pP+dENs5Io5XlG5Op2nsJF+y+LqbX6qbff9D/s4fTWyqKillpJN+48qs0wIBIw==",
"name": "chrome.metrics",
"version": "0.1",
"manifest_version": 2,
"description": "end-to-end browser test for chrome.metricsPrivate API",
"background_page": "test.html",
"permissions": ["metricsPrivate"]
......
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="test.js"></script>
<script>
chrome.test.runTests([
function hasPermission() {
chrome.test.assertEq(1, // permission not allowed
webkitNotifications.checkPermission());
chrome.test.succeed();
},
function showNotification() {
try {
window.webkitNotifications.createHTMLNotification(
chrome.extension.getURL("notification.html")).show();
} catch (e) {
chrome.test.assertTrue(e.message.indexOf("SECURITY_ERR") == 0);
chrome.test.succeed();
return;
}
chrome.test.fail("Expected access denied error.");
}
]);
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="background.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.runTests([
function hasPermission() {
chrome.test.assertEq(1, // permission not allowed
webkitNotifications.checkPermission());
chrome.test.succeed();
},
function showNotification() {
try {
window.webkitNotifications.createHTMLNotification(
chrome.extension.getURL("notification.html")).show();
} catch (e) {
chrome.test.assertTrue(e.message.indexOf("SECURITY_ERR") == 0);
chrome.test.succeed();
return;
}
chrome.test.fail("Expected access denied error.");
}
]);
{
"name": "notifications test",
"version": "1",
"manifest_version": 2,
"permissions": [ "tabs" ],
"background_page": "background.html"
}
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
Why hello there.
</html>
<script>
var notification = null;
var chromeExtensionsUrl = "chrome://extensions/";
// Shows the notification window using the specified URL.
// Control continues at onNotificationDone().
function showNotification(url) {
notification = window.webkitNotifications.createHTMLNotification(url);
notification.onerror = function() {
chrome.test.fail("Failed to show notification.");
};
notification.show();
}
// Called by the notification when it is done with its tests.
function onNotificationDone() {
var views = chrome.extension.getViews();
chrome.test.assertEq(2, views.length);
notification.cancel();
// This last step tests that crbug.com/40967 stays fixed.
var listener = function(tabId, changeInfo, tab) {
if (changeInfo.status != 'complete')
return;
// web_page1 loaded, open extension page to inject script
if (tab.url == chromeExtensionsUrl) {
console.log(chromeExtensionsUrl + ' finished loading.');
chrome.tabs.onUpdated.removeListener(listener);
chrome.test.succeed();
}
};
chrome.tabs.onUpdated.addListener(listener);
chrome.tabs.create({ url: chromeExtensionsUrl });
}
chrome.test.runTests([
function hasPermission() {
chrome.test.assertEq(0, // allowed
webkitNotifications.checkPermission());
chrome.test.succeed();
},
function absoluteURL() {
showNotification(chrome.extension.getURL("notification.html"));
},
function relativeURL() {
showNotification('notification.html');
}
]);
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="background.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var notification = null;
var chromeExtensionsUrl = "chrome://extensions/";
// Shows the notification window using the specified URL.
// Control continues at onNotificationDone().
function showNotification(url) {
notification = window.webkitNotifications.createHTMLNotification(url);
notification.onerror = function() {
chrome.test.fail("Failed to show notification.");
};
notification.show();
}
// Called by the notification when it is done with its tests.
function onNotificationDone() {
var views = chrome.extension.getViews();
chrome.test.assertEq(2, views.length);
notification.cancel();
// This last step tests that crbug.com/40967 stays fixed.
var listener = function(tabId, changeInfo, tab) {
if (changeInfo.status != 'complete')
return;
// web_page1 loaded, open extension page to inject script
if (tab.url == chromeExtensionsUrl) {
console.log(chromeExtensionsUrl + ' finished loading.');
chrome.tabs.onUpdated.removeListener(listener);
chrome.test.succeed();
}
};
chrome.tabs.onUpdated.addListener(listener);
chrome.tabs.create({ url: chromeExtensionsUrl });
}
chrome.test.runTests([
function hasPermission() {
chrome.test.assertEq(0, // allowed
webkitNotifications.checkPermission());
chrome.test.succeed();
},
function absoluteURL() {
showNotification(chrome.extension.getURL("notification.html"));
},
function relativeURL() {
showNotification('notification.html');
}
]);
{
"name": "notifications test",
"version": "1",
"manifest_version": 2,
"permissions": [ "notifications", "tabs" ],
"background_page": "background.html"
}
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<script>
// Test that we can call the tabs API. We don't care what the result is; tabs
// are tested elsewhere. We just care that we can call it without a
// permissions error.
chrome.windows.getAll(null, function() {
chrome.test.assertNoLastError();
chrome.extension.getBackgroundPage().onNotificationDone();
});
</script>
<script src="notification.js"></script>
Why hello there.
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Test that we can call the tabs API. We don't care what the result is; tabs
// are tested elsewhere. We just care that we can call it without a
// permissions error.
chrome.windows.getAll(null, function() {
chrome.test.assertNoLastError();
chrome.extension.getBackgroundPage().onNotificationDone();
});
<script>
var notification = null;
// Shows the notification window using the specified URL.
// Control continues at onNotificationDone().
function showNotification(url) {
notification = window.webkitNotifications.createHTMLNotification(url);
notification.onerror = function() {
chrome.test.fail("Failed to show notification.");
};
notification.show();
}
// Called by the notification when it is done with its tests.
function onNotificationDone(notificationWindow) {
var views = chrome.extension.getViews();
chrome.test.assertEq(2, views.length);
notificationWindow.onunload = function() {
chrome.test.succeed();
}
notification.cancel();
}
chrome.test.runTests([
function hasPermission() {
chrome.test.assertEq(0, // allowed
webkitNotifications.checkPermission());
chrome.test.succeed();
},
function absoluteURL() {
showNotification(chrome.extension.getURL("notification.html"));
},
function relativeURL() {
showNotification("notification.html");
}
]);
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="background.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var notification = null;
// Shows the notification window using the specified URL.
// Control continues at onNotificationDone().
function showNotification(url) {
notification = window.webkitNotifications.createHTMLNotification(url);
notification.onerror = function() {
chrome.test.fail("Failed to show notification.");
};
notification.show();
}
// Called by the notification when it is done with its tests.
function onNotificationDone(notificationWindow) {
var views = chrome.extension.getViews();
chrome.test.assertEq(2, views.length);
notificationWindow.onunload = function() {
chrome.test.succeed();
}
notification.cancel();
}
chrome.test.runTests([
function hasPermission() {
chrome.test.assertEq(0, // allowed
webkitNotifications.checkPermission());
chrome.test.succeed();
},
function absoluteURL() {
showNotification(chrome.extension.getURL("notification.html"));
},
function relativeURL() {
showNotification("notification.html");
}
]);
{
"name": "notifications test",
"version": "1",
"manifest_version": 2,
"permissions": [ "tabs" ],
"background_page": "background.html",
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHKlH3JTbOwICsw3EkXFfW+nWFTwuD2dZi1U+rQ143AUxYg2ZwG7+61RulNH//cYdo9YD5KAlbl+BMDsiKYexXVhddmaVJ1mlvW+oMoRR7MKuVeXNdLyAarsWrlnvWFjvhQ1AMSIlhKAEqilVblvmHg8PZ5tTE5PkV0V6vWs37DQIDAQAB"
......
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<script>
// Test that we can call the tabs API. We don't care what the result is; tabs
// are tested elsewhere. We just care that we can call it without a
// permissions error.
chrome.windows.getAll(null, function() {
chrome.test.assertNoLastError();
chrome.extension.getBackgroundPage().onNotificationDone(window);
});
</script>
<script src="notification.js"></script>
Why hello there.
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Test that we can call the tabs API. We don't care what the result is; tabs
// are tested elsewhere. We just care that we can call it without a
// permissions error.
chrome.windows.getAll(null, function() {
chrome.test.assertNoLastError();
chrome.extension.getBackgroundPage().onNotificationDone(window);
});
{
"name": "chrome.extension.omnibox",
"version": "0.1",
"manifest_version": 2,
"description": "end-to-end browser test for chrome.omnibox API",
"background_page": "test.html",
"incognito": "split",
......
<script>
var incognito = chrome.extension.inIncognitoContext;
var incognitoSuffix = incognito ? " incognito" : "";
chrome.omnibox.onInputChanged.addListener(
function(text, suggest) {
chrome.test.log("onInputChanged: " + text);
if (text == "suggestio") {
// First test, complete "suggestio"
var desc = 'Description with style: <match>&lt;match&gt;</match>, ' +
'<dim>[dim]</dim>, <url>(url till end)</url>';
suggest([
{content: text + "n1", description: desc},
{content: text + "n2", description: "description2"},
{content: text + "n3" + incognitoSuffix, description: "description3"},
]);
} else {
// Other tests, just provide a simple suggestion.
suggest([{content: text + " 1", description: "description"}]);
}
});
chrome.omnibox.onInputEntered.addListener(
function(text) {
chrome.test.assertEq("command" + incognitoSuffix, text);
chrome.test.notifyPass();
});
// Now we wait for the input events to fire.
chrome.test.notifyPass();
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="test.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var incognito = chrome.extension.inIncognitoContext;
var incognitoSuffix = incognito ? " incognito" : "";
chrome.omnibox.onInputChanged.addListener(
function(text, suggest) {
chrome.test.log("onInputChanged: " + text);
if (text == "suggestio") {
// First test, complete "suggestio"
var desc = 'Description with style: <match>&lt;match&gt;</match>, ' +
'<dim>[dim]</dim>, <url>(url till end)</url>';
suggest([
{content: text + "n1", description: desc},
{content: text + "n2", description: "description2"},
{content: text + "n3" + incognitoSuffix, description: "description3"},
]);
} else {
// Other tests, just provide a simple suggestion.
suggest([{content: text + " 1", description: "description"}]);
}
});
chrome.omnibox.onInputEntered.addListener(
function(text) {
chrome.test.assertEq("command" + incognitoSuffix, text);
chrome.test.notifyPass();
});
// Now we wait for the input events to fire.
chrome.test.notifyPass();
<script>
chrome.test.notifyPass();
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="background.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.notifyPass();
<script>
console.log('Overridden history page loaded.');
chrome.test.notifyPass();
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="history.js"></script>
History Override
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
console.log('Overridden history page loaded.');
chrome.test.notifyPass();
{
"name": "History override test",
"version": "0.1",
"description": "Test chrome://history/ override",
"background_page": "background.html",
"permissions": [
"history"
],
"chrome_url_overrides": {
"history": "history.html"
}
}
{
"name": "History override test",
"version": "0.1",
"manifest_version": 2,
"description": "Test chrome://history/ override",
"background_page": "background.html",
"permissions": [
"history"
],
"chrome_url_overrides": {
"history": "history.html"
}
}
<script>
chrome.test.notifyPass();
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="background.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.notifyPass();
<script>
chrome.test.notifyPass();
</script>
Keyboard Override!
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="keyboard.js"></script>
Keyboard Override!
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.notifyPass();
{
"name": "Keyboard override test",
"version": "0.1",
"description": "Test chrome://keyboard override",
"background_page": "background.html",
"chrome_url_overrides": {
"keyboard": "keyboard.html"
}
}
{
"name": "Keyboard override test",
"version": "0.1",
"manifest_version": 2,
"description": "Test chrome://keyboard override",
"background_page": "background.html",
"chrome_url_overrides": {
"keyboard": "keyboard.html"
}
}
<script>
chrome.test.notifyPass();
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="background.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.notifyPass();
<script>
chrome.test.notifyFail('this failure is expected');
</script>
Failing Keyboard Override!
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="keyboard.js"></script>
Failing Keyboard Override!
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.notifyFail('this failure is expected');
{
"name": "Keyboard override test",
"version": "0.1",
"description": "Test chrome://keyboard override",
"background_page": "background.html",
"chrome_url_overrides": {
"keyboard": "keyboard.html"
}
}
{
"name": "Keyboard override test",
"version": "0.1",
"manifest_version": 2,
"description": "Test chrome://keyboard override",
"background_page": "background.html",
"chrome_url_overrides": {
"keyboard": "keyboard.html"
}
}
<script>
chrome.test.notifyPass();
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="background.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.notifyPass();
{
"name": "New tab override test",
"version": "0.1",
"description": "Test chrome://newtab override",
"background_page": "background.html",
"permissions": [
"tabs"
],
"chrome_url_overrides": {
"newtab": "newtab.html"
}
}
{
"name": "New tab override test",
"version": "0.1",
"manifest_version": 2,
"description": "Test chrome://newtab override",
"background_page": "background.html",
"permissions": [
"tabs"
],
"chrome_url_overrides": {
"newtab": "newtab.html"
}
}
<script>
chrome.test.notifyPass();
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="newtab.js"></script>
New Tab Override!
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.test.notifyPass();
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<head>
</head>
<body>
......
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<body>
Another popup.
......
<script>
chrome.tabs.getSelected(null, function(tab) {
chrome.pageAction.show(tab.id);
// When the page action icon is clicked for the first time, add a popup.
chrome.pageAction.onClicked.addListener(function(tab) {
window.tabId = tab.id;
chrome.pageAction.setPopup({
tabId: tab.id,
popup: 'a_popup.html'
});
chrome.test.notifyPass();
});
chrome.test.notifyPass();
});
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="background.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.tabs.getSelected(null, function(tab) {
chrome.pageAction.show(tab.id);
// When the page action icon is clicked for the first time, add a popup.
chrome.pageAction.onClicked.addListener(function(tab) {
window.tabId = tab.id;
chrome.pageAction.setPopup({
tabId: tab.id,
popup: 'a_popup.html'
});
chrome.test.notifyPass();
});
chrome.test.notifyPass();
});
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<body>
<script>
chrome.tabs.getSelected(null, function(tab) {
chrome.pageAction.setPopup({
tabId: tab.id,
popup: 'another_popup.html'
});
chrome.test.notifyPass();
});
</script>
<script src="change_popup.js"></script>
</body>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.tabs.getSelected(null, function(tab) {
chrome.pageAction.setPopup({
tabId: tab.id,
popup: 'another_popup.html'
});
chrome.test.notifyPass();
});
{
"name": "A page action which adds a popup.",
"version": "1.0",
"manifest_version": 2,
"background_page": "background.html",
"permissions": [
"tabs", "http://*/*"
......
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<head>
<script>
// Called when the user clicks on the browser action.
chrome.pageAction.onClicked.addListener(function(windowId) {
chrome.test.notifyPass();
});
chrome.test.notifyPass();
</script>
<script src="background.js"></script>
</head>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Called when the user clicks on the browser action.
chrome.pageAction.onClicked.addListener(function(windowId) {
chrome.test.notifyPass();
});
chrome.test.notifyPass();
{
"name": "A page action with no icon that makes the page red",
"version": "1.0",
"manifest_version": 2,
"background_page": "background.html",
"permissions": [
"tabs", "http://*/*"
......
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<head>
<script>
// Test that we can change various properties of the browser action.
// The C++ verifies.
chrome.tabs.getSelected(null, function(tab) {
chrome.pageAction.show(tab.id);
chrome.pageAction.setTitle({title: "Modified", tabId: tab.id});
chrome.test.notifyPass();
});
</script>
<script src="update.js"></script>
</head>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Test that we can change various properties of the browser action.
// The C++ verifies.
chrome.tabs.getSelected(null, function(tab) {
chrome.pageAction.show(tab.id);
chrome.pageAction.setTitle({title: "Modified", tabId: tab.id});
chrome.test.notifyPass();
});
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<head>
</head>
<body>
<canvas id="canvas" width="27" height="23">
<script>
// Test that even if we set the icon after the extension loads, it shows up.
chrome.tabs.getSelected(null, function(tab) {
chrome.pageAction.show(tab.id);
chrome.pageAction.setIcon({tabId: tab.id,
imageData:document.getElementById("canvas")
.getContext('2d').getImageData(0, 0, 16, 16)});
chrome.test.notifyPass();
});
</script>
<script src="update2.js"></script>
</body>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Test that even if we set the icon after the extension loads, it shows up.
chrome.tabs.getSelected(null, function(tab) {
chrome.pageAction.show(tab.id);
chrome.pageAction.setIcon({tabId: tab.id,
imageData:document.getElementById("canvas")
.getContext('2d').getImageData(0, 0, 16, 16)});
chrome.test.notifyPass();
});
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
chrome.contextMenus.create({ type: "normal", title: "untitled", contexts: ["all"] });
</script>
<script type="text/javascript" src="background.js"></script>
</head>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.contextMenus.create({ type: "normal", title: "untitled", contexts: ["all"] });
{
"name": "Extension 1",
"version": "1.0",
"manifest_version": 2,
"description": "Extension for testing crash http://crbug.com/57333",
"background_page" : "background.html",
"icons": {
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
chrome.contextMenus.create({ type: "normal", title: "untitled", contexts: ["all"] });
</script>
<script type="text/javascript" src="background.js"></script>
</head>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.contextMenus.create({ type: "normal", title: "untitled", contexts: ["all"] });
{
"name": "Extension 2",
"version": "1.0",
"manifest_version": 2,
"description": "Extension for testing crash http://crbug.com/57333",
"background_page" : "background.html",
"icons": {
......
<!--
* Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<head>
<script>
// This makes sure we only enable the page action once per tab.
var hasEnabled = {};
chrome.extension.onRequest.addListener(function(request, sender) {
if (request.msg == "feedIcon") {
console.log('url: ' + sender.tab.url);
if (!hasEnabled[sender.tab.id]) {
console.log('Enabling for ' + sender.tab.id);
// We have received a list of feed urls found on the page.
// Enable the page action icon.
chrome.pageAction.setTitle({ tabId: sender.tab.id,
title: "Page action..."});
chrome.pageAction.show(sender.tab.id);
hasEnabled[sender.tab.id] = true;
hasEnabledLastTabId = sender.tab.id;
} else {
console.log('We are not doing this more than once (for ' +
sender.tab.id + ')');
}
}
});
</script>
<script src="background.js"></script>
</head>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This makes sure we only enable the page action once per tab.
var hasEnabled = {};
chrome.extension.onRequest.addListener(function(request, sender) {
if (request.msg == "feedIcon") {
console.log('url: ' + sender.tab.url);
if (!hasEnabled[sender.tab.id]) {
console.log('Enabling for ' + sender.tab.id);
// We have received a list of feed urls found on the page.
// Enable the page action icon.
chrome.pageAction.setTitle({ tabId: sender.tab.id,
title: "Page action..."});
chrome.pageAction.show(sender.tab.id);
hasEnabled[sender.tab.id] = true;
hasEnabledLastTabId = sender.tab.id;
} else {
console.log('We are not doing this more than once (for ' +
sender.tab.id + ')');
}
}
});
......@@ -11,5 +11,6 @@
"default_title": "Page action"
},
"permissions": [ "tabs", "http://*/*", "https://*/*" ],
"manifest_version": 2,
"version": "1.0"
}
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<head>
<script>
chrome.pageActions["action"].addListener(function(actionId, info) {
if (actionId == "action" && typeof(info.tabId) == "number" &&
typeof(info.tabUrl) == "string" && info.button == 1) {
chrome.test.notifyPass();
} else {
chrome.test.notifyFail("pageActions listener failed");
}
});
chrome.test.notifyPass();
</script>
<script src="background.js"></script>
</head>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.pageActions["action"].addListener(function(actionId, info) {
if (actionId == "action" && typeof(info.tabId) == "number" &&
typeof(info.tabUrl) == "string" && info.button == 1) {
chrome.test.notifyPass();
} else {
chrome.test.notifyFail("pageActions listener failed");
}
});
chrome.test.notifyPass();
{
"name": "Test of old-style page actions API",
"version": "1.0",
"manifest_version": 2,
"background_page": "background.html",
"permissions": ["tabs"],
"page_actions": [
......
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<body>
<script>
// Enable the page action on this tab.
chrome.tabs.getSelected(null, function(tab) {
chrome.pageActions.enableForTab("action", {"tabId":tab.id, "url":tab.url});
chrome.test.notifyPass();
});
</script>
<script src="page.js"></script>
</body>
</html>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Enable the page action on this tab.
chrome.tabs.getSelected(null, function(tab) {
chrome.pageActions.enableForTab("action", {"tabId":tab.id, "url":tab.url});
chrome.test.notifyPass();
});
<script>
chrome.tabs.getSelected(null, function(tab) {
chrome.pageAction.show(tab.id);
chrome.test.notifyPass();
});
</script>
<!--
* Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<script src="background.js"></script>
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.tabs.getSelected(null, function(tab) {
chrome.pageAction.show(tab.id);
chrome.test.notifyPass();
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment