diff --git a/.assets/sample.idl b/.assets/sample.idl new file mode 100644 index 0000000..5c72c95 --- /dev/null +++ b/.assets/sample.idl @@ -0,0 +1,115 @@ +// Copyright 2013 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. + +// Use the chrome.webrtcLoggingPrivate API to control diagnostic +// WebRTC logging. +namespace webrtcLoggingPrivate { + dictionary MetaDataEntry { + // The meta data entry key. + DOMString key; + + // The meta data entry value. + DOMString value; + }; + + dictionary UploadResult { + // The report ID for the uploaded log. Will be empty if not successful. + DOMString reportId; + }; + + dictionary RequestInfo { + // The tab identifier from the chrome.tabs API, if the request is from a + // tab. + long? tabId; + + // The guest process id for the requester, if the request is from a + // webview. + long? guestProcessId; + }; + + callback GenericDoneCallback = void (); + callback UploadDoneCallback = void (UploadResult result); + + interface Functions { + // For all functions, |request| determines which render process to apply + // the operation on. |request| identifies the requesting process. + // |securityOrigin| is the security origin for the tab identified by |tabId| + // and is used for verifying that the tab is the correct one and has not + // been navigated away from. + + // Sets additional custom meta data that will be uploaded along with the + // log. |metaData| is a dictionary of the metadata (key, value). + static void setMetaData(RequestInfo request, + DOMString securityOrigin, + MetaDataEntry[] metaData, + GenericDoneCallback callback); + + // Starts logging. If logging has already been started for this render + // process, the call will be ignored. |appSessionId| is the unique session + // ID which will be added to the log. + static void start(RequestInfo request, + DOMString securityOrigin, + GenericDoneCallback callback); + + // Sets whether the log should be uploaded automatically for the case when + // the render process goes away (tab is closed or crashes) and stop has not + // been called before that. If |shouldUpload| is true it will be uploaded, + // otherwise it will be discarded. The default setting is to discard it. + static void setUploadOnRenderClose(RequestInfo request, + DOMString securityOrigin, + boolean shouldUpload); + + // Stops logging. After stop has finished, either upload() or discard() + // should be called, otherwise the log will be kept in memory until the + // render process is closed or logging restarted. + static void stop(RequestInfo request, + DOMString securityOrigin, + GenericDoneCallback callback); + + // Stores the current log without uploading. The log may stay around for + // as much as 5 days. The application has the option of supplying an id + // for uniquely identifying the log for later upload via a call to + // uploadStored(). + static void store(RequestInfo request, + DOMString securityOrigin, + DOMString logId, + GenericDoneCallback callback); + + // Uploads a previously kept log that was stored via a call to store(). + // The caller needs to know the logId as was originally provided in the + // call to store(). + static void uploadStored(RequestInfo request, + DOMString securityOrigin, + DOMString logId, + UploadDoneCallback callback); + + // Uploads the log and the RTP dumps, if they exist. Logging and RTP dumping + // must be stopped before this function is called. + static void upload(RequestInfo request, + DOMString securityOrigin, + UploadDoneCallback callback); + + // Discards the log. Logging must be stopped before this function is called. + static void discard(RequestInfo request, + DOMString securityOrigin, + GenericDoneCallback callback); + + // Starts RTP dumping. If it has already been started for this render + // process, the call will be ignored. + static void startRtpDump(RequestInfo request, + DOMString securityOrigin, + boolean incoming, + boolean outgoing, + GenericDoneCallback callback); + + // Stops RTP dumping. After stop has finished, the dumps will be + // uploaded with the log if upload is called. Otherwise, the dumps will be + // discarded. + static void stopRtpDump(RequestInfo request, + DOMString securityOrigin, + boolean incoming, + boolean outgoing, + GenericDoneCallback callback); + }; +}; diff --git a/tests/lib/idl-convert.js b/tests/lib/idl-convert.js new file mode 100644 index 0000000..53ac18e --- /dev/null +++ b/tests/lib/idl-convert.js @@ -0,0 +1,36 @@ +/** + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import test from 'ava'; +import { convertFromIdl } from '../../tools/lib/idl-convert.js'; +import { fetchAllTo } from '../../tools/lib/chrome-source.js'; +import { toolsPaths } from '../../tools/prepare.js'; +import { chromeVersions } from '../../tools/lib/chrome-versions.js'; + +test('convertFromIdl', async (t) => { + // Make sure IDL still generated + const filename = '.assets/sample.idl'; + let root = process.cwd(); + + if (process.env.CI) { + const {head} = await chromeVersions() + await fetchAllTo(root, toolsPaths, head); + } + + await t.notThrowsAsync(() => + convertFromIdl(root, filename) + ); +}); diff --git a/tools/prepare.js b/tools/prepare.js index 5ea3f72..d95600d 100755 --- a/tools/prepare.js +++ b/tools/prepare.js @@ -51,7 +51,7 @@ const definitionPaths = [ /** * Fetch these folders to run the IDL => JSON converter. */ -const toolsPaths = [ +export const toolsPaths = [ 'tools/json_schema_compiler', 'tools/json_comment_eater', 'ppapi/generators',